Jsp:将当前日期输出为 “2017-12-27 11:11 星期三”格式

function getNow() {
    var d = new Date();
    var year = d.getFullYear();
    var month = d.getMonth();
    var date = d.getDate();
    var hour = d.getHours();
    var minute = d.getMinutes();
    var week = d.getDay();
    if  (minute < 10){
        minute = "0" + minute;
    }
    var weekStr = ["星期日",
                   "星期一",
                   "星期二",
                   "星期三",
                   "星期四",
                   "星期五",
                   "星期六"];
    console.log(year + "-"+ (month+1)+"-"+date+" "+hour+":"+minute+" "+weekStr[week])
}
getNow()
posted @ 2020-05-17 16:50  Lance_王  阅读(236)  评论(0编辑  收藏  举报