Js get time difference remove implementation code on Saturday and Sunday

Source: Internet
Author: User

Copy codeThe Code is as follows:
Function GetDayNum (no, type ){
If (type = "35 "){
Var num7 = document. getElementById ("6"). value;
Var value = document. getElementById ("7"). value;
Var valueR = num7;
If (no = "7") {valueR = value;} // identifies the time value
If (num7! = "" & Value! = "") {// The BUG1 can be integrated in two time periods
Var numValue = 0;
Var numValue = 0;
Var day = 24*60*60*1000;
Var dateArr = value. split ("-");
Var checkDate = new Date ();
CheckDate. setFullYear (dateArr [0], dateArr [1]-1, dateArr [2]);
Var checkTime = checkDate. getTime ();
Var dateArr2 = num7.split ("-");
Var checkDate2 = new Date ();
CheckDate2.setFullYear (dateArr2 [0], dateArr2 [1]-1, dateArr2 [2]);
Var checkTime2 = checkDate2.getTime ();
Var numValue = (checkTime-checkTime2)/day; // The total number of days of the difference

Var totleWeek = numValue/7; // how many weeks are different?
Var yuDay = numValue % 7; // except for the day of the week
Var lastDay = 0;
Var startWeek = num7.replace (/-/g, "/"); // change "-" to "/", where "-" is not accurate. I tested it.
// Var date = new Date (parseInt (startWeek [0]), parseInt (startWeek [1]), parseInt (startWeek [2]);
Var date = Date. parse (startWeek );
Var dateNew = new Date (date );
Var weekDay = dateNew. getDay (); // day of the week
Var endWeekDay = 0; // the remaining days are Saturday or Sunday.
If (weekDay = 6 & yuDay> = 2) | (weekDay = 7 & yuDay> = 1) | (weekDay = 5 & yuDay> = 3) | (weekDay = 4 & yuDay> = 4) | (weekDay = 3 & yuDay> = 5) | (weekDay = 2 & yuDay> = 6) | (weekDay = 1 & yuDay> = 7 )){
EndWeekDay = 2; www.jb51.net
}
If (weekDay = 6 & yuDay <1) | (weekDay = 7 & yuDay <5) | (weekDay = 5 & yuDay <2) | (weekDay = 4 & yuDay <3) | (weekDay = 3 & yuDay <4) | (weekDay = 2 & yuDay <5) | (weekDay = 1 & yuDay <6 )){
EndWeekDay = 1;
}
// If (numValue = 0) {numValue = 1 ;}
NumValue = numValue-(totleWeek * 2)-endWeekDay; // the final time.

}
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.