The timestamp of the date is 8:00 of the day?

Date format: 2022-10-10, when the obtained timestamp is converted to the date, it is found that the date has changed to 8 o'clock!

new Date('2022-10-10').getTime();
> 1665360000000

new Date(1665360000000);
> Mon Oct 10 2022 08:00:00 GMT+0800 (中国标准时间)

Date format: 2022/10/10, when the obtained timestamp is converted back to date, there is no exception!

new Date('2022/10/10').getTime();
> 1665331200000
new Date(1665331200000);
> Mon Oct 10 2022 00:00:00 GMT+0800 (中国标准时间)

Convert 2022-10-10 to 2022/10/10

var a='2022-10-10';
a.replace("/-/g","/");
> "2022-10-10"

Guess you like

Origin blog.csdn.net/LzzMandy/article/details/126401473
Recommended