Php calculates the number of days for different dates. php date difference days _ PHP Tutorial

Source: Internet
Author: User
Php calculates the number of days for different dates. Php calculates the number of days for different dates. This document describes how to calculate the number of days for different dates in php. Share it with you for your reference. Implementation Method: php calculates the number of days for different dates, and php calculates the number of days for different dates.

This example describes how php calculates the number of days for two different dates. Share it with you for your reference. The specific implementation method is as follows:

<? Php/*** calculate the number of days between two dates * (the Taylor formula can be used before the calculation after January 1, January 1, 1970) * @ param string $ day1 * @ param string $ day2 * @ return number */function diffBetweenTwoDays ($ day1, $ day2) {$ second1 = strtotime ($ day1 ); $ second2 = strtotime ($ day2); if ($ second1 <$ second2) {$ tmp = $ second2; $ second2 = $ second1; $ second1 = $ tmp ;} return ($ second1-$ second2)/86400;} $ day1 = "2013-07-27"; $ day2 = "2013-08-04"; $ diff = diffBetweenTwoDays ($ day1, $ day2 ); echo $ diff. "\ n ";

I hope this article will help you with php programming.

Examples in this article describes how php calculates the number of days for two different dates. Share it with you for your reference. Implementation method...

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.