Home
Web Front-end
JS Tutorial
js takes the time difference and removes Saturday and Sunday implementation code_javascript skills



js takes the time difference and removes Saturday and Sunday implementation code_javascript skills
May 16, 2016 pm 05:45 PM
Time difference
Copy code The 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;}//Identify the time value
if (num7 != "" && value != "") {//Two time periods can be merged BUG1
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; //Total number of days difference
var totleWeek = numValue / 7; //How many weeks difference
var yuDay = numValue % 7; //Except the number of days in the entire week
var lastDay = 0;
var startWeek = num7.replace(/-/g, "/"); //Change "-" to "/", where "-" is not accurate in calculating time. I tested this
//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; //Excessive How many 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; //Final time
}
}
}
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update?
3 weeks ago
By 王林
Two Point Museum: All Exhibits And Where To Find Them
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot tools Tags

Hot Article
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update?
3 weeks ago
By 王林
Two Point Museum: All Exhibits And Where To Find Them
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Replace String Characters in JavaScript

HTTP Debugging with Node and http-console

Custom Google Search API Setup Tutorial
