Calculate the number of days in these periods based on the specified two dates.

Source: Internet
Author: User

Introduction: This is to calculate the number of days in these periods based on the specified two dates.ProgramFunctionCodeThe details page of PHP, related knowledge, skills, experience, and some PHP source code.

Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 343705 'scrolling = 'no'> $ alldays = intval (sstrtotime ($ _ post ['day'])-sstrtotime ($ _ post ['daya']) /3600/24) + 1; // Total Number of days
$ Weeks = intval ($ alldays/7); // week count
$ Mdays = $ alldays-7 * $ weeks; // the remaining days of the week except the number of weeks.
If ($ mdays = '0 '){
$ _ Post ['psdays '] = 5 * $ weeks;
$ _ Post ['zmdays'] = 2 * $ weeks;
} Else {
$ Aday = ''; // the day of the week on the first day.
$ Adays = date ("D", sstrtotime ($ _ post ['daya ']);
If ($ adays = 'mon '){
$ Aday = "1 ";
} Elseif ($ adays = 'tue '){
$ Aday = "2 ";
} Elseif ($ adays = 'wed '){
$ Aday = "3 ";
} Elseif ($ adays = 'thu '){
$ Aday = "4 ";
} Elseif ($ adays = 'fri '){
$ Aday = "5 ";
} Elseif ($ adays = 'sat '){
$ Aday = "6 ";
} Else {
$ Aday = "7 ";
}
If ($ aday = '7 '){
$ _ Post ['zmdays'] = 1 + 2 * $ weeks;
$ _ Post ['psdays '] = $ mdays-1 + 5 * $ weeks;
} Else {
$ Nfanwei = 7-$ aday; // range, starting from the day of the week $ aday (including this day), and from $ nfanwei to Saturday
If ($ mdays> $ nfanwei ){
$ _ Post ['zmdays'] = 2 + 2 * $ weeks;
$ _ Post ['psdays '] = $ mdays-2 + 5 * $ weeks;
} Elseif ($ mdays ==$ nfanwei ){
$ _ Post ['zmdays'] = 1 + 2 * $ weeks;
$ _ Post ['psdays '] = $ mdays-1 + 5 * $ weeks;
} Else {
$ _ Post ['zmdays'] = 0 + 2 * $ weeks;
$ _ Post ['psdays '] = $ mdays + 5 * $ weeks;
}
}
}

Address: http://www.corange.cn/archives/2011/08/3781.html

Love J2EE follow Java Michael Jackson video station JSON online tools

Http://biancheng.dnbcw.info/php/343705.html pageno: 5.

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.