JS gets this week’s weekend function examples on Monday, weekends and access to any time

This example describes the JS acquisition of Monday Weekend features this week, weekend and acquisition time. Share to everyone for reference, specifically:

Items need to get this week and any day on Monday and weekend needs formatting, the sample code is as follows:

     Week   / ** * @Author zhuyangxing * / (function () {function util_date () {var _today = new date (); THIS.TODAY = _Today; this.year = _today.getyear () + 1900; // Current Year THISMONTH_A = _Today.GeTMONTH (); this.month = this.month_a + 1; // Current month THIS.DAY = _Today.getdate (); // Current date this.date = _today.getday () == 0? 7: _Today.getDay (); // This week, the system will take Sunday as day 0 this day. Monday = ""; this.sunday = "; this.day_one =" ";} Date.Prototype.pattern = function (fmt) {var o = {" m + ": this.getMonth () + 1, // month "D +": this.getdate (), // day "h +": this.GetHours ()% 12 == 0? 12: this.getHours ()% 12, // hour "h +": this.GetHours () , //Hour"m +": this.getminutes (), // division "s +": this.getseconds (), // second "q +": Math.Floor ((this.getmonth () + 3) / 3), // quarter "S": this.getmilliseconds () // millisecond}; var week = {"0": "/ u65e5", "1": "/ u4e00", "2": "/ u4e8c", "3": ":" / U4E09, "4": "/ u56db", "5": "/ u4e94", "6": "/ u516d"}; if (/ (y +) /. test (fmt)) {fmt = fmt. Replace (regexp. $ 1, (this.Getfullyear () + ""). Substr (4 - regexp. $ 1.length);} f (/ (e +) /. test (fmt)) {fmt = fmt.replace Regexp. $ 1 ((Regexp. $ 1.length> 1)? (Regexp. $ 1.length> 2? "/ U661f / u671f": "/ u5468"): "") + week [this.getday () + " "]);} for (VAR K IN O) {IF (" + K + ")") "). Test (FMT) {FMT = FMT.Replace (regexp. $ 1, (regexp. $ 1. Length == 1)? (o [k]): ("00" + O [k]). Substr (("" + O [k]). Length)))))))))))}}}}}} THIS.MONTH = this.month_a + 1; // Current month this.day = _today.getdate (); // Current date this.date = _today.getday () == 0? 7: _today.getday (); // This week, the system will use Sunday as the day 0 this.monday = ""; this.sunday = "";}, getmonday: function ()}. Monday.length! = 0) {return this.monday;} else {var _monday = new date (this.year, this.month_a, this.day-this.date + 1); this.monday = _monday; return _monday; }}, getSunday: function () {i (this.sunday.length! = 0) {Return this.sundaY;} else {var _Sunday = new date (this.year, this.month_a, this.day-this.date + 7); this.sunday = _Sunday; return _sunday;}}, getpreviousmonday: function (monday) {var _Monday = new Date (Monday.getyear () + 1900, Monday.getMonth (), Monday.getdate () - 7); return_monday;}, getprevioussunday: function (monday) {var _ssay = new date (monday.getyear) ) + 1900, Monday.getMonth (), Monday.getdate () - 1); this.sunday = _Sunday; return_sunday;}, getnextmonday: function (monday) {var _monday = new date (monday.getyear () + 1900 Monday.getMonth (), monday.getdate () + 7); return_monday;}, getnextsunday: function (monday) {var _ssay = new date (Monday.GetyEAR () + 1900, Monday.getMonth (), monday.getdate () + 13); this.Sunday = _Sunday; return_sunday;}}; window.util_date = new util_date ();}) (); document.write (window.util_date         
Introducing this file directly in the project using Window.util_Date.getMonday (). Pattern (“YYYY-MM-DD”); available 2017-1-24 type string

WINDOW.UTIL_DATE.NEWTODAY (“2017-1-1”); set the current date
   
PS: Here you recommend a few times and Date-related tools for your reference:

Online Date / Day Calculator: http://tools.jb51.net/jisuanqi/date_jisuanqi

Online Date Calculator / Paste Day Calculator:
http://tools.jb51.net/jisuanqi/datecalc

Online Japanese Difference Calculator:
http://tools.jb51.net/jisuanqi/onlinedatejsq

UNIX Timestamp Conversion Tool: http://tools.jb51.net/code/unixtime
More about JavaScript Related Contents Readers can view this site: “JavaScript Time and Date Operation Skills Summary”, “JavaScript Finding Algorithm Skill Summary”, “JavaScript Error and Debugging Skill Summary”, “JavaScript Data Structure and Algorithm Skill Summary”, “JavaScript Broadcast Algorithm and Skill Summary” and “Summary of JavaScript Mathematical Computing Law”

Hope The JavaScript program design is helpful in this article.

© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment