时间戳转换成日期格式方法

function changedate(shijianchuo) {
var now = new Date(shijianchuo),
y = now.getFullYear(),
m = ("0" + (now.getMonth() + 1)).slice(-2),
d = ("0" + now.getDate()).slice(-2);
return y + "-" + m + "-" + d + " " + now.toTimeString().substr(0, 8);
}

posted @ 2017-11-23 17:30  符木诗  阅读(1142)  评论(0)    收藏  举报