JS获取当前时间

//获取当前日期
        Date.prototype.Format = function (fmt) { //author: meizz 
            var o = {
                    "M+": this.getMonth() + 1, //月份 
                    "d+": this.getDate(), //
                    "h+": this.getHours(), //小时 
                    "m+": this.getMinutes(), //
                    "s+": this.getSeconds(), //
                    "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
                    "S": this.getMilliseconds() //毫秒 
            };

            if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            for (var k in o)
                if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
            return fmt;
        }
        var time2 = new Date().Format("yyyy-MM-dd hh:mm:ss");  

 获取当前日期是一年中的第几个星期

function(event) {
        var d1 = new Date();
        var d2 = new Date();
        d2.setMonth(0);
        d2.setDate(1);
        var rq = d1 - d2;
        var s1 = Math.ceil(rq / (24 * 60 * 60 * 1000));
        var s2 = Math.ceil(s1 / 7);
        // alert("今天是本年第"+s1+"天,第"+s2+"周");//周日做为下周的开始计算
        return s2;
    };
-------------------------------------------------------------------------------------------------------------------------------------------------------- 目前的博客发表主要以记录笔记为主,可能部分内容有些浅显,望各路大牛勿喷,请您雅正
原文地址:https://www.cnblogs.com/404code/p/8419410.html