javascript时间格式转换

将获取到的时间转换成“yyyy-MM-dd hh:mm:ss”格式

var time = new Date();//或者获取的时间格式为"2018-09-27T05:52:10.709+0000"时
function formateTime(time) {
    var d = new Date(time);
    var times = d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate()+ ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds(); ;
    return times;
}

猜你喜欢

转载自www.cnblogs.com/lk617-home/p/9713424.html