1. The conversion date stamp format:
var date = new Date('2018-06-08 18:00:00'); // There are three ways to obtain var time1 = date.getTime(); var time2 = date.valueOf(); var time3 = Date.parse(date); console.log(time1);//1528452000000 console.log(time2);//1528452000000 console.log(time3);//1528452000000
Apple will use this phone because the middle spaces cause results to date is NaN, the date can be divided and then converted
was str = '2018-06-08 18:00:00';
var time=new Date(str.split(" ")).getTime();
2. timestamp into a Date format:
function timestampToTime(timestamp) { var DATE = new new a Date (timestamp * 1000); // time stamp is required * 10 1000, the timestamp is not required by the case 13 1000 var Y = date.getFullYear() + '-'; var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-'; var D = date.getDate() + ' '; var h = date.getHours() + ':'; var m = date.getMinutes() + ':'; var s = date.getSeconds(); return Y+M+D+h+m+s; } timestampToTime(1528452000); console.log(timestampToTime(1528452000));//2018-06-08 18:00:00
Gangster link
https://blog.csdn.net/weixin_42333548/article/details/80539239