jQuery Grid v 15.1.20151.1005
I'm binding the JSON results of an AJAX query to the grid as follows:
$.ajax({ type : 'GET', url : env_constants.DATASERVICES_URL + '/ar_invoices', data : params, dataType : 'json', success : function(invoiceRows) { $("#ar_invoices").igGrid("option", "dataSource", invoiceRows); $("#ar_invoices").igGrid( "resizeContainer" ); }, error : function(jqXHR, textStatus, errorThrown) { alert(jqXHR.responseText); } });
When I examine the first object of invoiceRows in the browser's debugger I see this field: { invoiceDate : "2015-07-25" }
However, the grid displays this date as "07/24/2015". Similarly, the date 8/1/2015 is displayed as "7/31/2015".
Could the grid be parsing this date format wrong? Perhaps applying a timezone adjustment to it?
Thanks,
Matt
Hello Matthew,
Please make sure that you have enabled enableUTCDates option in case that your date values are coming from a backend with a different time zone than the client machine. If this does not help resolving your issue, then a sample demonstrating it would be great appreciated. Please let me know for further questions.
Regards,
Tsanna
Tsanna,
enableUTCDates does fix it.
I'd like to understand why this works though. The grid is being passed "YYYY-MM-DD". The grid seems to be assuming that incoming date strings are UTC if they have no timezone on them (i.e. no Z suffix, and no "+h:00" specified). So the grid converts it to local time if enableUTCDates=false. Is my interpretation right?
(FYI if I'm understanding the ISO 8601 standard correctly this may be a bug. I think if there is no Z suffix or explicit timezone, then the time should already be assumed to be in local time.)