Home JQuery获取当前日期
Post
Cancel

JQuery获取当前日期

1
2
3
4
5
6
7
8
9
10
11
12
13
function getNowDate(){
    var myDate = new Date;
    var year = myDate.getFullYear(); // 获取当前年
    var mon = myDate.getMonth() + 1; // 获取当前月
    var date = myDate.getDate(); // 获取当前日
    var h = myDate.getHours(); // 获取当前小时数(0-23)
    var m = myDate.getMinutes(); // 获取当前分钟数(0-59)
    var s = myDate.getSeconds(); // 获取当前秒
    var week = myDate.getDay();
    var weeks = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
    return year + "" + mon + "" + date + "" + " " 
    + h + "" + m + "" + s + "" + " " + weeks[week];
}
This post is licensed under CC BY 4.0 by the author.