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
Whoops! It seems that I didn't read Steven's blog post to the end :DNow I see that you suggest using his implementation of the dateFormat function (its ColdFusion counterpart was mentioned at the start of the article - this is why I became suspicious of ColdFusion to begin with)So sorry for the misunderstanding - I agree that using Steven's function is a good way to handle UTC/local dates.Cheers!
You just need to import the downloaded JS file in your page and you can use that function. Why it is difficult to use that function, I didn't understood.
I am not using Cold fusion framework but still I can use that. It's just a JS File and in JS File as well there is no ColdFusion Dependency as well. I don't know why you are relating this to ColdFusion framework.
Can you please explain, If I am wrong. So I can correct myself.
Thanks
Hi Jamil,Glad you found a solution that works for you :)However, I'd like to mention that as the article you linked to mentions, the dateFormat function comes from the Adobe's proprietary ColdFusion framework.Thus, this isn't a solution that can be easily applied by other people who aren't using that framework.Angel's suggestion is a bit more cumbersome, but it can be applied without the need for any other 3rd party framework or library.Cheers,Borislav
I solved my problem like this:
If you use this javascript library for date formating http://blog.stevenlevithan.com/archives/date-time-format
then you can use in your grid for specific date time column like this
....
columns: [ { headerText: "Read DateTime", key: "ReadDateTime", dataType: "date", formatter: function (date) { var currentDate = dateFormat(date, "dd/mm/yyyy HH:MM", true); console.log(currentDate); return currentDate; }, width: "185px" } ]
dateFormat(yourDateObject,formatmask,utcTrueOrFalse)
Example:
"2012-09-25T00:15:00" from web api controller or mvc controller action.
"25/09/2012 00:15" after using this function. If I don't use this function and only use igrid format: "dd/MM/yyyy HH:mm" it renders "25/09/2012 01:15".
just to confirm, this property does exactly what you have requested and expect - it treats and converts all dates to UTC, when enabled. for that purpose, all of this api is used
- getUTCFullYear()
- getUTCMonth()
- getUTCDate()
as compared to the equivalent Date object api, but without the "UTC" part
hope it helps. thanks,
Angel