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
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 = newDate(timestamp).toISOString();
let date = kendo.parseDate(isoDate);
console.log(date)
</script>
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/.