Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kendo DateTimePicker Not Handling UTC Offset

We are using the Kendo datetimepicker, implemented using the AngularJS directives:

<input type="text" kendo-date-time-picker k-ng-model="TheDateModel">

Where: TheDateModel = 2016-02-15 20:58:24.0000000 +00:00

I am in the CST timezone, which is -6 hour offset from the GMT. The current result of the datetimepicker shows a time of 8:58 pm but my expected result is 2:58 pm.

What in the world am I doing wrong?

like image 574
Mike Avatar asked Feb 02 '26 16:02

Mike


1 Answers

Disclaimer: I work for Kendo UI team

The Kendo UI Datepicker uses JavaScript Date object internally to hold the selected date value. As you probably know, it always uses the local (browser) timezone. We tried to explain that caveat in our docs too:

  • JavaScript Date Object - Basics

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

Solution

The best approach in this case is to convert the Date strings (like the one you mentioned "2016-02-15 20:58:24.0000000 +00:00") manually before feed the DatePicker widget. For instance, here is one possible approach to do that:

  • http://dojo.telerik.com/EyuRA

Notice how the value is parsed and then adjusted in the loadData method. Similar thing should be done by the developer that needs to handle different TZ in their app.

like image 107
George K Avatar answered Feb 05 '26 06:02

George K