// 获取当前时间戳的示例代码
// 方法1: 使用 Date.now()
let timestamp1 = Date.now();
console.log("当前时间戳 (方法1):", timestamp1);
// 解释: Date.now() 返回自 1970 年 1 月 1 日 00:00:00 UTC 到现在的毫秒数。
// 方法2: 使用 new Date().getTime()
let timestamp2 = new Date().getTime();
console.log("当前时间戳 (方法2):", timestamp2);
// 解释: new Date().getTime() 创建一个新的 Date 对象并调用 getTime() 方法,返回自 1970 年 1 月 1 日 00:00:00 UTC 到现在的毫秒数。
上一篇:js tcp
下一篇:js 获取本地ip
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站