blog
blog copied to clipboard
Date(时间转换)
- 格林威治时间戳转换本地时间
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"