Date value inside Grid getting reduced by a day depending on the Client Machine's Time Zone

2 posts, 0 answers
  1. Ketan
    Ketan avatar
    1 posts
    Member since:
    Apr 2012

    Posted 14 Jan 2014 Link to this post



    Steps to reproduce the issue:

    1. Open the Telerik asp.net mvc grid page shown in the below link.

    http://demos.telerik.com/aspnet-mvc/razor/Grid/EditingAjax?theme=vista

    2. Click on Add New Record button and enter a date in one of the date pickers in the grid. Click on save button.

    3. Now change the TimeZone of your machine to a TimeZone which is running at least a few hours behind your current Time Zone and refresh the entire page (Ctrl+F5).

    4. If there is a major time difference between the newly selected timezone and your default timezone then the previously saved date would get reduced by a day. For example: if the date you had saved was 1/1/2014 it would get changed to 12/31/2013.

    5. Could you please help understand why this is happening and provide a solution that would prevent the date being reduced by a day depending on the client machine's time zone.

    Thanks.
  2. Alexander Popov
    Admin
    Alexander Popov avatar
    1441 posts

    Posted 15 Jan 2014 Link to this post

    Hello Ketan,

    This happens because the Date objects in JavaScript  are always created with a timezone offset according to the operating system's clock. I would suggest checking this KendoUI project, which demonstrates how to use UTC time on both client and server.

    On a side note I would like to remind you that as of June 2013, Telerik Extensions for ASP.NET MVC has reached its official End of Life, with no additional fixes or enhancements expected in the future. I would strongly recommend migrating to KendoUI for ASP.NET MVC as we no longer provide support for the Telerik Extensions.

    Regards,
    Alexander Popov
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top