600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > 将毫秒转换为年月日时分秒

将毫秒转换为年月日时分秒

时间:2018-07-28 23:26:36

相关推荐

将毫秒转换为年月日时分秒

translateTime(time) {//将毫秒转换为年月日时分秒

if (!time) {

return "";

} else {

let date = new Date(time);//时间戳为10位需*1000,时间戳为13位的话不需乘1000

let Y = date.getFullYear() + '-';

let M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';

let D = date.getDate() + ' ';

let h = date.getHours() + ':';

let m = date.getMinutes() + ':';

let s = date.getSeconds();

return Y+M+D+h+m+s;

}

}

例如: translateTime(20000000000)

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。