根據時間戳獲取年月日時分秒


// 根據時間戳獲取年月日時分秒
function getYMDHMS(time) {
    var year = time.getFullYear(),
        month = time.getMonth() + 1,
        date = time.getDate(),
        hours = time.getHours(),
        minute = time.getMinutes(),
        second = time.getSeconds();

    if (month < 10) { month = '0' + month; }
    if (date < 10) { date = '0' + date; }
    if (hours < 10) { hours = '0' + hours; }
    if (minute < 10) { minute = '0' + minute; }
    if (second < 10) { second = '0' + second; }

    return {
        year: year,
        month: month,
        date: date,
        hours: hours,
        minute: minute,
        second: second
    }  //不想要對象的情況下 直接返回 //return year+'年'+ month+'月'+date+'日'+hours+':'+minute+':'+second
} 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM