Converting date to tick when the date has a time as 00:00:00 results in previous days tick

55 Views Asked by At

I have a date as Sun Oct 01 2023 00:00:00 GMT+0530 (India Standard Time) which i'm trying to convert to the time tick as below

overlapDetails is an array with data as [{start: Sun Oct 01 2023 00:00:00 GMT+0530 (India Standard Time), end: Wed Oct 04 2023 00:00:00 GMT+0530 (India Standard Time)}]

 overlapDetails.forEach((dateDetails)=>{  const startDates =  ((dateDetails['start']* 10000) + 621355968000000000) })
   

the above conversion works perfectly when the time part of date is not 00:00:00, but in case it is 00:00:00 it creates a time tick of previous date,so by using the above conversion formula I get time tick as '638316954000000000'

But when checked if the timetick(638316954000000000) generated a proper date or not using online converter https://www.datetimetoticks-converter.com/ the date recieved was 30/09/2023 18:30:00.

The expected conversion to time tick should be 638317152000000000 , got this value from the same online converter mentioned above https://www.datetimetoticks-converter.com/.

What should be the fix for the issue, because if we add secs or mins to date that would be wrong so what doing that how to get expected tick value in case if time is 00:00:00

0

There are 0 best solutions below