# 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

# 其他编程语言获取unix时间戳

传送门

Last Updated: 1/23/2022, 10:16:22 AM