I was given a JSON file with timestamps.
One of them is:
I was able to get the actual date by doing:
new Date(ticket.creationTime).toLocaleString(), and it gave me:
Now, I tried converting the date:
27/12/2018 by doing:
new Date(Number(split),Number(split),Number(split)).getTime(), and got:
Which is very different, and especially very larger. This is a huge problem since I’m comparing them to sort them by creation time.
Anyone knows why do they differ? And how can I get the equivalent of case1?
It is because Date api takes month as number starting from 0, in this case it needs to be 11 instead of 12
new Date(Number(split),Number(split) - 1,Number(split)).getTime()
But it also won’t give exact 1545880457898, because we are not providing time to Date api