JS获取本周、本季度、本月、上月的开始日期、结束日期
-
-
var now = new Date();
-
var nowDayOfWeek = now.getDay();
-
var nowDay = now.getDate();
-
var nowMonth = now.getMonth();
-
var nowYear = now.getYear();
-
nowYear += (nowYear < 2000) ? 1900 : 0;
-
var lastMonthDate = new Date();
- lastMonthDate.setDate(1);
- lastMonthDate.setMonth(lastMonthDate.getMonth()-1);
-
var lastYear = lastMonthDate.getYear();
-
var lastMonth = lastMonthDate.getMonth();
-
-
function formatDate(date) {
-
var myyear = date.getFullYear();
-
var mymonth = date.getMonth()+1;
-
var myweekday = date.getDate();
-
-
if(mymonth < 10){
-
mymonth = "0" + mymonth;
- }
-
if(myweekday < 10){
-
myweekday = "0" + myweekday;
- }
-
return (myyear+