kendo.parsedate

1 Answer 158 Views
Grid
Mina
Top achievements
Rank 1
Mina asked on 02 Sep 2021, 06:11 PM

kendo.parseDate("/Date(-62135537400000)/")

 

it returns Mon Jan 01 0001 08:37:02 GMT-0752 (Pacific Standard Time) I need the time and it is 8:30 it is adding 7 minutes, start happening recently it was working on the page since 2018.

 

 

1 Answer, 1 is accepted

Sort by
0
Georgi Denchev
Telerik team
answered on 07 Sep 2021, 10:26 AM

Hi, Mina,

The problem occurs due to the fact that negative timestamps may be inaccurate when converting the date to a Javascript object.

This is not something controlled by us, here is the result of the Date Object itself:

I am not certain as to why it has been working before, perhaps you had some sort of manual conversion which handled the UNIX dates. You could convert the timestamp to an ISO string and then parse it using the kendo.parseDate() method, this should return the correct value.

  <script>
    let timestampString = "/Date(-62135537400000)/";
    
    // Returns -62135537400000 as a string and converts it to a number.
    let timestamp = +timestampString.substring(timestampString.indexOf('(') + 1, timestampString.indexOf(')'));
    
    let isoDate = new Date(timestamp).toISOString();
    let date = kendo.parseDate(isoDate);
    
    console.log(date)
  </script>

Dojo:

https://dojo.telerik.com/@gdenchev/IgIHOJeJ 

Best Regards,
Georgi Denchev
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Mina
Top achievements
Rank 1
Answers by
Georgi Denchev
Telerik team
Share this question
or