时间转为时间戳 timeToTimestamp(time){ let timestamp = Date.parse(time) return timestamp; } 时间戳转为本地时间 timestampToTime(timestamp){ let date = new Date(timestamp); var YY = date.getFullYear() + '-'; var MM = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() +…
近几天,在做百度地图时,需要转换时间格式并做显示,但是发现显示的时间格式,出现了错乱,二者的日期和小时都出现了变动.例如: 原始时间格式:Thu Aug 18 20:38:54 CST 2016 转换时间格式:2016-08-19 10:38 使用的代码如下: //Thu Aug 18 20:38:54 CST 2016 function getTaskTime(strDate) { console.log("原始时间格式:"+strDate); var date = new Date…