This article describes how to calculate the number of days for two different dates in php. The example analyzes the php operation date skills, for more information about how to calculate the number of days for different dates in php, see the example in this article. 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.