编程语言

Node.JS 获取时间戳(毫秒,秒)

daimafengzi · 4月21日 · 2022年本文共324个字 · 预计阅读2分钟161次已读

Warning: Undefined variable $case in /mnt/H1/luoweihua.cn/wp-content/themes/niRvana/custom_function.php on line 110
/**
 * 获取当前时间戳(毫秒)
 */
function getNowMilliSecond(){
	return Math.floor(Date.now());
}
 
/**
 * 获取当前时间戳(秒)
 */
function getNowSceond(){
	return Math.floor(Date.now() / 1000);
}
 
//当前时间戳(毫秒)
console.log("curMilliSecond=%d",getNowMilliSecond());   //输出:curMilliSecond=1608090151913
//当前时间戳(秒)
console.log("curSecond=%d",getNowSceond());             //输出:curSecond=1608090151
0 条回应
| 耗时 0.426 秒 | 查询 52 次 | 内存 4.18 MB |
本站CDN由One degree CDN提供