This is a migrated thread and some comments may be shown as answers.

Browser Local DateTime Time Zone Conversions

2 Answers 1279 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Joel
Top achievements
Rank 2
Iron
Iron
Iron
Joel asked on 21 Nov 2019, 05:21 PM

How do I display the Local DateTime in your control?  Razor renders everything on the Server but I need to display DateTime values in the context of the Browser's TimeZone.  Couple of scenarios:

  • I want to pull the DateTime value from the browser using JavaScript and display it in your Browser. 
  • I have a UTC DateTime value stored in the database but when displaying that value I need it to display in the TimeZone of the browser.
  • I have a DateTime with the Offset stored in the database.  How do I display that value in the TimeZone of the broswer.

Is there some type of event that I can tie in to that could be used to call an Action on my Controller similar to your other (Grid, Hierarchy) controls that would supply the TimeZone information?

2 Answers, 1 is accepted

Sort by
0
Accepted
Nikolay
Telerik team
answered on 26 Nov 2019, 03:12 PM

Hello Joel,

The Kendo UI Datepicker uses JavaScript Date object internally to hold the selected date value. It always uses the local (browser) timezone. This could be found explained in the following article: https://docs.telerik.com/kendo-ui/controls/scheduling/scheduler/timezones#basics

Due to this default behavior, the component will use the already converted Date value (with the applied local timezone). The DateTimePicker does not manipulate the value timezone, as it does not have sufficient information on how to do that.

The best approach here is to convert the Date strings manually before feed the DatePicker component. For instance, here is one possible approach to do that:

Below I am posting two articles on the topic you may find useful:

Please let me know if you have any questions.

Regards,


Nikolay
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Joel
Top achievements
Rank 2
Iron
Iron
Iron
answered on 26 Nov 2019, 05:17 PM
Thanks for the thorough answer.
Tags
Date/Time Pickers
Asked by
Joel
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Nikolay
Telerik team
Joel
Top achievements
Rank 2
Iron
Iron
Iron
Share this question
or