js獲取時間 本週 本季度 本月

2021-09-23 05:56:08 字數 917 閱讀 5255

封裝成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 dateutil = ,

/*** 獲得本週的開始時間

* * @returns

*/getstartdayofweek : function() ,

/*** 獲得本週的結束時間

* * @returns

*/getenddayofweek : function() ,

/*** 獲得本月的開始時間

* * @returns

*/getstartdayofmonth : function() ,

/*** 獲得本月的結束時間

* * @returns

*/getenddayofmonth : function() ,

/*** 獲得本月天數

* * @returns

*/getmonthdays : function() ,

/*** @param 日期格式化

* @returns

*/formatdate : function(date)

if (myweekday < 10)

return (myyear + "-" + mymonth + "-" + myweekday);

}};

js獲取時間 本週 本季度 本月

獲取本週 本季度 本月 上月的開端日期 停止日期 var now new date 當前日期 var nowdayofweek now.getday 今天本週的第幾天 var nowday now.getdate 當前日 var nowmonth now.getmonth 當前月 var nowye...

獲取 當前時間 本週,本月,本季度,本年的起始時間

因為專案中需要用時間作為條件進行統計,所以需要獲取 當前時間 本週,本月,本季度,本年的起始時間,如下 1 region 獲取 本週 本月 本季度 本年 的開始時間或結束時間 2 3 統計時間型別 4 5public enum enumtimetype612 13 獲取結束時間 14 15 week...

根據當前時間獲取,本週,本月,本季度等時間段

當前時間 1 d 本週周一 6 本週週日 1 本月月初 1 adddays 1 本月月末 本月月末 0 1 3 adddays 1 本季度初 3 adddays 1 本季度末 new11 本年年初 new 1231 本年年末 至於昨天 明天 上週 上月 上季度 上年度等等,只要adddays add...