How does the Date in js specify the translation time zone?

for example, now x = 1526559600000
Date (x) returns Beijing time UTC+8 time zone time, when in fact this is a UTC+0 time zone time. Please take a look at

.
Mar.12,2021

1. Timestamp
let timestamp = Date.now ();
ask a question, does running this line of code in different time zones return the same value? The answer is the same. The timestamp of
JS refers to the number of milliseconds from a place from a previous point to the present.
if you are in Greenwich, your start time is 01 00 minutes and 00 seconds on January 1, 1970.
if you are in Beijing, China, your starting time is 08 on January 1, 1970.

so, the timestamp is without time zone information.

put it more clearly.
I got the timestamp in Beijing: let timestamp = Date.now ();
while you use this timestamp to generate a time object new Date (timestamp) in the United States, it is 12 hours slower than me.

2. Conversion time
Local time minus the difference between the local time and the time zone of the target location, which has nothing to do with the timestamp.


https://blog.csdn.net/u012193.


you x minus the 8-hour timestamp


npm install moment

Menu