JavaScript时间戳与时间字符串的转换
1. 时间戳为
Date.parse('2017-01-23T18:30:11+08:00')
Date.parse(new Date('2017-01-23 18:30:11'))
1485167411000
2. 时间戳换成时间格式字符串
var newDate = new Date();
newDate.setTime(1485167411000);
newDate.toDateString() // Mon Jan 23 2017
newDate.toGMTString() // Mon, 23 Jan 2017 10:30:11 GMT
newDate.toISOString() // 2017-01-23T10:30:11.000Z
newDate.toJSON() // 2017-01-23T10:30:11.000Z
newDate.toLocaleDateString() // 1/23/2017
newDate.toLocaleString() // 1/23/2017, 6:30:11 PM
newDate.toLocaleTimeString()); // 6:30:11 PM
newDate.toString() // Mon Jan 23 2017 18:30:11 GMT+0800 (CST) (中国标准时间)
newDate.toTimeString() // 18:30:11 GMT+0800 (CST)
newDate.toUTCString() // Mon, 23 Jan 2017 10:30:11 GMT