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

Difference in kendo.toString value for chrome and IE

3 Answers 194 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 1
Adam asked on 15 Apr 2020, 01:24 AM

In tracking down a datepicker display issue, I've found that kendo.toString returns a different value for some dates on Chrome than it does in IE.

Here is an example that differs:

kendo.toString(kendo.parseDate("\/Date(-1316628000000)\/"), "MM/dd/yyyy")

 

The datepicker uses kendo.toString to set the input element value. Unfortunately, this can actually mess up data if a datepicker is set with javascript and sent to the server with a full post.

 

 

What's going on here?

3 Answers, 1 is accepted

Sort by
0
Preslav
Telerik team
answered on 16 Apr 2020, 03:52 PM

Hi Adam,

I tested the scenario, and the provided code seems to provide the same output in both IE(11.1039) and Chrome(80) on my side. I used the following test page:

https://dojo.telerik.com/UmeWICUL

Having said that, could you please elaborate on the exact scenario of your app?

Further, on a side note, the Kendo "toString" method is using the JavaScript "toString" internally - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toString

There is a possibility that the IE user agent has a different implementation of this method.

 

Regards,
Preslav
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Adam
Top achievements
Rank 1
answered on 16 Apr 2020, 04:58 PM

Ok, I tried the test page and was able to verify the issue. In IE (11.0.9600) I get the expected "04/12/1928" and in Chrome (80) I get "04/11/1928"

However, I just tried changing my timezone to CST and EST and I get the same expected result in both browsers, so it seems to be some timezone issue. If you change your timezone to MST I think you will be able to replicate the issue. If I change to PST I get "04/11/1928" in both browsers. It's only MST (the timezone that the date was serialized in) that the issue exists.

The scenario is a date being serialized by MVC 5 default serializer (System.Web.Helpers) like so:

@Html.Raw(Json.Encode(new DateTime(1928, 4, 12))

This is then passed to a kendo Model/ObservableObject and the web page has a kendo date picker with value binding to the field. Both server and client in MST timezone.

The strange this is that this only affects certain dates and I don't understand why. It's like a 10% chance that chrome shows the previous day. The example below works as expected in both browsers:

Json.Encode(new DateTime(1980, 8, 12))
kendo.toString(kendo.parseDate("\/Date(334908000000)\/"), "MM/dd/yyyy")

I am able to resolve the issue by using Newtonsoft serializer which serializes datetime differently, but am concerned about the data integrity issues that were possibly introduced by this.

Any ideas?

Thanks.

0
Preslav
Telerik team
answered on 20 Apr 2020, 11:38 AM

Hello Adam,

I did a quick search, and indeed, there are a lot of issues relating to the timezones and the different browsers. For example - https://stackoverflow.com/questions/41859774/getting-different-result-in-ie-and-chrome-when-converting-utc-date-time-into-loc

Based on what I read, I see no straight-forward way to resolve this issue. Having said that, I believe you should use a workaround that best fits your app requirements.

 

Regards,
Preslav
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Date/Time Pickers
Asked by
Adam
Top achievements
Rank 1
Answers by
Preslav
Telerik team
Adam
Top achievements
Rank 1
Share this question
or