JS 获取当前年份,月份

function doHandleDate() {
    var myDate = new Date();
    var tYear = myDate.getFullYear();
    var tMonth = myDate.getMonth();

    var m = tMonth + 1;
    if (m.toString().length == 1) {
        m = "0" + m;
    }
    return tYear +'-'+ m;
}
function doHandleYear(tYear) {
    var myDate = new Date();
    var tYear = myDate.getFullYear();

    return tYear;
}
function doHandleMonth() {
    var myDate = new Date();
    var tMonth = myDate.getMonth();

    var m = tMonth + 1;
    if (m.toString().length == 1) {
        m = "0" + m;
    }
    return m;
}

 

posted @ 2019-06-13 13:55  格鲁特baby  阅读(271)  评论(0编辑  收藏  举报