Laravel  
laravel
文档
数据库
架构
入门
php技术
    
Laravelphp
laravel / php / java / vue / mysql / linux / python / javascript / html / css / c++ / c#

js timestamp

作者:似水韶华该惜谁ら   发布日期:2026-05-12   浏览:93

// 获取当前时间的时间戳(以毫秒为单位)
let timestamp = Date.now();
console.log(timestamp); // 输出类似 1633072800000 的数字,表示自1970年1月1日以来的毫秒数

// 或者使用 new Date().getTime() 方法
let timestamp Alternative = new Date().getTime();
console.log(timestampAlternative); // 输出类似 1633072800000 的数字

// 将时间戳转换为日期对象
let date = new Date(timestamp);
console.log(date); // 输出类似 "2021-10-01T00:00:00.000Z" 的日期字符串

// 创建指定时间的日期对象并获取其时间戳
let specificDate = new Date('2021-10-01');
let specificTimestamp = specificDate.getTime();
console.log(specificTimestamp); // 输出 1633027200000

上一篇:js date格式化

下一篇:js format日期

大家都在看

js 数组打乱顺序

js 两个数组取交集

js 数组对象排序

js 对象数组排序

js 数组删掉第一个值

js fill

js fill方法

js 数组连接

js json数组

js 数组复制

Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3

Laravel 中文站