//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);
时间: 2024-10-02 10:54:14