時間戳
備注:
? 時間戳包括10位和13位兩種,小程序中默認生成的時間戳是13位的。兩者的區(qū)別是精度不同,13位精確到毫秒,10位精確到秒。實際上,13位時間戳只是比10位的末尾多了000,如果想要轉(zhuǎn)化只要乘除1000即可。
// 將時間戳( times )轉(zhuǎn)換成指定日期格式
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
}