獲取本週周一,週末 獲取任意時間的周一週末

2021-06-20 07:57:35 字數 856 閱讀 7588

專案需要獲取本週及任意一天的周一及週末 需格式化

/**

* @author zhuyangxing

* @createdate 2014-1-24

*/(function()

date.prototype.pattern=function(fmt) ;

var week = ;

if(/(y+)/.test(fmt))

if(/(e+)/.test(fmt))

for(var k in o)

}

return fmt;

}, util_date.prototype = ,

getmonday:function()else

},getsunday:function()else

},getpreviousmonday:function(monday),

getprevioussunday:function(monday),

getnextmonday:function(monday),

getnextsunday:function(monday)

}; window.util_date = new util_date();

})();

如果需要可直接在專案中引入該檔案 使用window.util_date.getmonday().pattern("yyyy-mm-dd");可獲得2014-1-24型別的字串

window.util_date.newtoday("2014-1-1");設定當前日期

js獲取本週周一的日期

var nowtemp new date 當前時間 var onedaylong 24 60 60 1000 一天的毫秒數 var c time nowtemp.gettime 當前時間的毫秒時間 var c day nowtemp.getday 7 當前時間的星期幾 var m time c ti...

Calendar獲取上週周一至本周一的日期

tabstudydetailed record null date date new date datetime 取上週一 00 00 00 calendar cal1 calendar.getinstance cal1.settime date int n1 1 n為推遲的週數,1上週,0本週,1...

C 獲取周一 週日的日期

datetime dt datetime.now 當前時間 datetime startweek dt.adddays 1 convert.toint32 dt.dayofweek.tostring d 本週周一 datetime endweek startweek.adddays 6 本週週日 d...