日期补0和获取日期

function fillZero(param) {
    return param < 10 ? ("0" + param) : param;
}
//获取完整的日期  
function y() {
    var today = new Date();
    var y = today.getFullYear();
    return y
}

function m() {
    var today = new Date();
    var m = (today.getMonth() + 1) < 10 ? "0" + (today.getMonth() + 1) : (today.getMonth() + 1);
    return m
}

function d() {
    var today = new Date();
    var d = today.getDate() < 10 ? "0" + today.getDate() : today.getDate();
    return d
}

function hh() {
    var today = new Date();
    var hh = today.getHours() < 10 ? "0" + today.getHours() : today.getHours();
    return hh
}

function mm() {
    var today = new Date();
    var mm = today.getMinutes() < 10 ? "0" + today.getMinutes() : today.getMinutes();
    return mm
}

你可能感兴趣的:(日期补0和获取日期)