Date getTime () returns different values โ€‹โ€‹on individual machines

According MDN repeatedly , new Date():

creates an instance of JavaScript JavaScript that represents one moment in time. Date objects are based on a time value, which is the number of milliseconds since January 1, 1970. UTC

when it comes to getTime():

Returns the numeric value of the specified date as the number of milliseconds since January 1, 1970, 00:00:00 UTC (negative for previous times).

Why statement:

new Date(new Date(1, 0, 1).setFullYear(1)).getTime();

which are supposed to return the number of milliseconds from January 1, 1970, 00:00:00 UTC to 01/01/0001 12:00:00 AM, gives different values โ€‹โ€‹on separate machines, for example. -62135600400000and -62135596800000? Do local time zones (or system times?) Affect this logic in some way?

+4
2

:

. Date . UTC (Date.UTC(...)) .

+2

, - .

:

new Date(Date.UTC(year, month, day, hour, minute, second)) 

Date UTC.

mdn Date.UTC()

+1

Source: https://habr.com/ru/post/1624303/


All Articles