jQWidgets Forums

jQuery UI Widgets Forums Grid Grid Date Field Different Than MySQL

This topic contains 1 reply, has 1 voice, and was last updated by  Hop 11 years, 5 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Grid Date Field Different Than MySQL #30458

    Hop
    Participant

    I noticed something strange this morning while trying to troubleshoot an issue with data loaded into a grid from mysql. The dates in the date column of my grid are one day earlier than what the dates are in mysql. This would explain why the dates I see in the grid are one day earlier than the date I pass as a parameter.

    Is this something I need to set in the dataAdapter? Could it be a formatting issue?

    I just noticed the same behavior with the calendar widget. I call a function to get the most recent date from my database. The function returns ‘2013-03-01’ in startdate. I set the value and setDate in the calendar using
    $("#jqxcalendar").jqxCalendar({ width: '240px', height: '220px', value: $.jqx._jqxDateTimeInput.getDateTime(new Date(startdate))});
    $("#jqxcalendar").jqxCalendar('setDate',new Date(startdate));

    and the date that is selected is February 28. One day earlier.

    Please advise and thank you for your time!

    EDIT: Live and learn. I found another post here about the same problem, and after reading about formatting the fields, I added that to my code as in { name: 'date', type: 'date',format: "yyyy-MM-dd"}, and that fixed the dates in my grid. I still have the problem with my calendar though.

    Grid Date Field Different Than MySQL #30464

    Hop
    Participant

    I got this working now too. This makes total sense now that I understand why. For someone looking for an answer like I was, I found my answer on stack overflow. Apparently, the date is parsed as UTC with midnight as the time, so when GMT-0700 factors in, the date returned is the day before. Parsing the MYSQL formatted date down into month, day, and year and using the date constructor via a function solved this for me. Now my calendar shows the actual date selected and not the day before.

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

You must be logged in to reply to this topic.