js 格式化UTC日期

 //格式化日期,2018-05-21T10:54:56.955+08:00 ——> 2018-05-21 18:54:56

function formatUtcTime(v) {
    let date = new Date(v);
    return date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章