今天为一年中的第几周

//JS
var today = new Date();//获取当前时间
            var y = today.getFullYear();
           var m = today.getMonth()+1;
           var d = today.getDate();
           
             var getYearWeek = function (a, b, c) {
                var date1 = new Date(a, parseInt(b) - 1, c), date2 = new Date(a, 0, 1),
                d = Math.round((date1.valueOf() - date2.valueOf()) / (3600 * 24 * 1000)),weekday = date2.getDay();//四舍五入整数
                return Math.ceil( (d + weekday) / 7 );//上舍入 天数
             };
               var w = getYearWeek(y,m,d);
                            console.log(w);

 

posted on 2016-11-22 01:40  小乔流水人家  阅读(170)  评论(0编辑  收藏  举报

导航