jQWidgets Forums

jQuery UI Widgets Forums Editors DateTimeInput Time not being set

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by  Jazz 11 years, 4 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • Time not being set #31400

    Jazz
    Participant

    Time values are not being displayed correctly in jqxDateTimeInput widgets as far as I can tell. In my app, all times are being shown as “12:00:00 AM”.

    I thought this was something I was doing, but it appears the demo is doing the same thing. The demo is also showing the same time (12:00:00 AM), when I’m assuming it is supposed to be showing the current time?

    I’m not doing anything special and I’m running the latest code (3.0.3). Browser is Google Chrome on Linux. Also tried Firefox with the same result.

    Can someone check this out and confirm there’s a problem?

    Example of how I’m using it:

    <div id="dateStart"></div>
    <script>
    $("#dateStart").jqxDateTimeInput( { theme: 'arctic', width : 300, height : 25, formatString : "dd/MM/yyyy HH:mm tt" });
    //Setting the date/time
    $('#dateStart').jqxDateTimeInput('setDate', new Date());
    </script>

    I would think that the setDate call would set the date AND time to the current date and time, but it only sets the date. The time is still 12:00:00 AM.

    Time not being set #31406

    Peter Stoev
    Keymaster

    Hi Jazz,

    According to me, the date and time are set correctly via the “setDate” method. However, please note that the Format String that is used in the provided code is not correct. You use 24hrs Format String, but with AM/PM,too.

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css"/>
    <script type="text/javascript" src="../../scripts/jquery-1.10.2.min.js"></script>
    <script type="text/javascript" src="../../scripts/demos.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxdatetimeinput.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxcalendar.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxtooltip.js"></script>
    <script type="text/javascript" src="../../jqwidgets/globalization/globalize.js"></script>
    </head>
    <body>
    <div id='content'>
    <script type="text/javascript">
    $(document).ready(function () {
    // Create jqxDateTimeInput and set its format string to Time.
    // Set the showCalendarButton option to hide the calendar's button.
    $("#jqxWidget").jqxDateTimeInput({ width: '250px', height: '25px', formatString: 'F'});
    $("#jqxWidget").jqxDateTimeInput('setDate', new Date());
    });
    </script>
    <div id='jqxWidget'></div>
    </div>
    </body>
    </html>

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

    Time not being set #31493

    Jazz
    Participant

    Peter, yeah, the ‘tt’ shouldn’t be there. However using just ‘F’ I still get the same problem. Pasting your above code in worked for me so I found the problem.

    Turns out my helper function, which generates the Javascript code for me, was adding “{ value : null }” to the parameters passed to the jqxDateTimeInput function and that is what was messing things up.

    So, THIS is bad:

    $("#jqxWidget").jqxDateTimeInput({ width: '250px', height: '25px', formatString: 'F', value: null });

    Guess I had just been staring at it too long yesterday. All sorted now.

    Thanks,

    Jamie

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.