Kendogrid automatically converting the date to local timezone
1 Answer 12 Views
Sesha
Top achievements
Rank 1
Sesha asked on 15 Jun 2021, 02:03 PM

Hi,

 

I have a date in my database (25/08/2020). When I try to display it in the kendo grid, it is shown as 25/08/2020 (Expected) for me. But some of the users from USA are shown 24/08/2020. After some debugging, I found that the local timezone conversion is done based on the browsers timezone settings. Anyway we can exclude this automatic conversion globally?

 

Option available so far but not suitable:

 

1. Convert the date to string and display. This means I lose all the functions of using date type.

 

2. Have UTC time in both client and server. This is a tedious process as the application is huge and cannot do this change.

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 18 Jun 2021, 06:22 AM

Hello Sesha,

By default, the Grid creates its date objects on the client immediately after they are received from the server. Based on the current time, the default JavaScript date object automatically adds the time offset. The default behavior is such because the date objects demonstrate the same default behavior and most users expect to see the date in its current timezone.

The best practice in such cases is to keep a DateTime property in a UTC format on both server and client when using a Grid with Ajax binding and editing. Please refer to the following article supplying information on how that can be achieved: 

Note that the DataSource requestEnd event is handled the dates are converted manually in order to be in UTC time. You can use similar logic in your scenario in order to adjust the dates.

Regards,
Nikolay
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Asked by
Sesha
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or