时间戳
备注:
时间戳包括10位和13位两种,小程序中默认生成的时间戳是13位的。两者的区别是精度不同,13位精确到毫秒,10位精确到秒。实际上,13位时间戳只是比10位的末尾多了000,如果想要转化只要乘除1000即可。
// 将时间戳( times )转换成指定日期格式
formateTime( times ) {
let date = new Date( times*1000 )
let year = date.getFullYear()
let month = date.getMonth() + 1
let dates = date.getDate()
return year + "." + month + "." + dates
}
网友评论