您的位置:首页 > 其它

十三位时间戳换成日期格式xxxx-mm-dd

2019-06-08 12:11 14 查看
function getLocalTime(nS) {
//将时间戳(十三位时间搓,也就是带毫秒的时间搓)转换成时间格式
// d.cTime = 1539083829787
let date = new Date(nS);
let year = date.getFullYear();
let month = date.getMonth()+1;
let day = date.getDate();
month = month < 10 ? "0"+month:month;
day = day < 10 ? "0"+day:day;
date = year+'-'+month+'-'+day;
console.log(date); // 2018-10-09
return date;
}

转载至:https://blog.csdn.net/jianqiangdexiaohai/article/details/84561461

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: