js实现将时间戳转换成2017-05-06 09:03:02

var date = new Date(1494032584000);
year = date.getFullYear() + '-';
month = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
dates = (date.getDate() < 10 ? '0'+(date.getDate()) : date.getDate())+ ' ';
hour = (date.getHours() < 10 ? '0'+(date.getHours()) : date.getHours())+ ':';
minute = (date.getMinutes() < 10 ? '0'+(date.getMinutes()) : date.getMinutes())+ ':';
second = (date.getSeconds() < 10 ? '0'+(date.getSeconds()) : date.getSeconds());
timeStamp = year+month+dates+hour+minute+second;
console.log(timeStamp)//呀麻碟

゛Toly★小饼干ゞ
原文地址:https://www.cnblogs.com/rockyan/p/7724353.html