# Unix时间戳
- 在有一些接口文档中看到过也叫
UTC时间戳
# js获取当前时间unix时间戳
- 方法一
let now = Math.round(new Date().getTime()/1000)
1
- 方法二
let now = new Date()
let unixTimeStamp = Math.round(Date.UTC(now.getUTCFullYear(),
now.getUTCMonth(),
now.getUTCDate(),
now.getUTCHours(),
now.getUTCMinutes(),
now.getUTCSeconds(),
now.getUTCMilliseconds()
) / 1000)
1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9