js获取日期时间

function getNowFormatDate() { //获取当前时间
    var date = new Date();
    var symbol_gang = "-";
    var symbol_maohao = ":";
    var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
    var strDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
    var currentdate = date.getFullYear() + symbol_gang + month + symbol_gang + strDate
        + " " + date.getHours() + symbol_maohao + date.getMinutes()
        + symbol_maohao + date.getSeconds();
    return currentdate;
}
上一篇:1034 Head of a Gang (30 point(s)) - C语言 PAT 甲级


下一篇:[LeetCode] 879. Profitable Schemes 盈利计划