Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1390
Handling of UTC Dates
posted

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

Parents Reply
  • 140
    posted in reply to Alexander Todorov

    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".

Children