Date
Date()
Section titled “Date()”// 当前时间,返回Sun Dec 17 1995 03:24:00 GMTconst now = new Date();
// 返回Sun Nov 26 1989 02:30:00 GMTconst birthday = new Date(628021800000);
// 返回Wed Jan 01 2025 08:00:00 GMTconst fromString = new Date('2025-01-01');Timestamp
Section titled “Timestamp”时间戳是从 1970年1月1日 00:00:00 UTC(Unix 纪元)到指定时间的毫秒数
// 获取当前时间戳const timestamp = Date.now();// 或const timestamp = new Date().getTime();
// 从时间戳还原日期,返回Sun Dec 17 1995 03:24:00 GMTconst date = new Date(timestamp);