js格式化格林威治時間

格式化時間:Sat Aug 05 00:00:00 CST 2017post

function fermitTime(time){
    var now = new Date(time);
    var year = now.getFullYear();
    var mon = now.getMonth()+1;
    var date= now.getDate();
    if(mon<10){
        mon = '0'+mon;
    };
    if(date<10){
        date = '0'+date;
    }
    var postDate = year+'-'+mon+'-'+date;
    return postDate;
}

time="Sat Aug 05 00:00:00 CST 2017";

alert(fermitTime(time));    
相關文章
相關標籤/搜索