Hi, I'm recieving UTC dates from the server formatted as JSON, what I want to find out is how the grid handles UTC date. displaying the dates as local time received from the server and to the server when filering on date columns?
Please can u advice on how to resolve this issue.
Thanks in advanced.
Regards Christoff
Hi Angel
Thanks for the response; I ended up using the following formatter function resulting into the correct local time.
formatter: function (date) { return Globalize.format( new Date(date.getTime() + (new Date().getTimezoneOffset() * -60000)), $.ig.regional.defaults.dateTimePattern); }
But it will be very appreciated if the grid could support UTC dates and local culture formats.
Thanks Christoff
Hi,
i will discuss with our product manager regarding any plans to add this feature to the grid. Thanks for the feedback, it's very valuable !
regarding the date format, i think it would be even more suitable to work with already parsed Date objects, because you can always get the ticks from that object, add the timezone offset milliseconds, and that will result in your local date.
here is an example that should work
function formatDate(theValue) {
var msUTC = theValue.UTC(); // assuming it's a Date object
var newVal = new Date(msUTC + offset);
// where offset can be taken like this: var offset = new Date().getTimezoneOffset();
return newVal;
}
Hope it helps. Thanks,
Angel
Hi Angel, thanks for the response.
As you stated the grid does not support automatic culture. Will it be supported in the future? And if when?
Until then how do I get acces to the raw (original) date json string to be able to parse the date using jquery.globalize? Currently the json date string is already parsed by the time it is passed to the formatter function, and I am unable to translate it to local time?
the grid doesn't add any timezone offsets on the client. It just renders and formats the dates as UTC.
What kind of scenario are you trying to implement, related to culture? would you like to apply specific format depending on the culture? In that case you can set a format or implement a formatter (per column). The grid's rendering doesn't have automatic culture support, such as adding currency signs , etc.
Thanks
Hey Angel
If I can explain this a little bit more clearly.
I receive the date from the server in the format: /Date(1334837100843)/ (Witch is an UTC date)
On the column definition I have:
{
headerText: "Received",
key: "Received",
dataType: "date",
format: "dateTime",
width: 45
},
After the date is rendered the date is displayed as: 4/19/2012 12:05 PM
But the correct local value should be: 4/19/2012 14:05 PM
If I project the value like so: new Date(1334837100843), I do get the correct 4/19/2012 14:05 PM value.
Another thing I am having trouble with is that your jquery editors do have support for culture information, but could not find the same functionality on the grid control.