blog icon indicating copy to clipboard operation
blog copied to clipboard

Date(时间转换)

Open yongheng2016 opened this issue 7 years ago • 0 comments

  • 格林威治时间戳转换本地时间
let time = 1517305179000
let LocalDay = new Date(time)  //Tue Jan 30 2018 17:39:39 GMT+0800 (中国标准时间)

LocalDay.toLocaleString('chinese',{hour12:false})  //  2018/1/30 17:39:39 
下面类推
LocalDay.toLocaleString()  //"2018/1/30 下午5:39:39"
LocalDay.toLocaleDateString()  //  "2018/1/30"
LocalDay.toLocaleTimeString()  //  "下午5:39:39"

yongheng2016 avatar Jan 31 '18 03:01 yongheng2016