[JS] The reason for the 8-hour difference in time format conversion

The reason why the time format conversion differs by 8 hours

time type

UTC

Coordinated Universal Time, also known as Universal Time, Universal Standard Time, International Coordinated Time, referred to as UTC (Coordinated Universal Time)
UTC+8 is Beijing time, which is currently generally considered UTC and GMT are consistent (0.9s difference)

UTC时间格式: YYYY-MM-DDThh:mm:ssZ
例如:2023-06-12T02:00:00Z
北京时间为202306111000

Note: Adding Z after hours, minutes and seconds indicates UTC time, and not adding Z indicates local time.

GMT

It is Greenwich Mean Time, GMT+8 is Beijing time

CST

It can be regarded as the standard time in China and Cuba or the central time in the United States and Australia. 8 hours ahead of UTC.

The reason for the 8-hour difference in time conversion

Insert image description here
The reason for the 8-hour difference in time conversion from ① to ② (speculation): The system knows that the local time is Beijing time, so it thinks it is converting Beijing time to UTC time and automatically subtracts 8 hours.

Guess you like

Origin blog.csdn.net/LookForDream_/article/details/131164013