This article mainly introduces the PHP calculation date difference of days method, combined with examples of PHP date and time operation and conversion of the relevant skills, the need for friends can refer to the following
This paper analyzes the method of calculating the date difference between days in PHP. Share to everyone for your reference, as follows:
<? php//today and October 27, 2016 The difference of how many days $date_1=date ("y-m-d"), $Date _2= "2016-10-27"; $d 1=strtotime ($Date _1); $d 2=strtotime ($Date _ 2); $Days =round (($d 1-$d 2)/3600/24); Echo "Today differs from October 27, 2016". $Days. " Day ", echo" <br> ";//How many days $date_1=date (" y-m-d ") to September 9, 2018, $Date _2=" 2018-09-09 "; $d 1=strtotime ($Date _1); $d 2 = Strtotime ($Date _2); $Days =round (($d 2-$d 1)/3600/24); Echo "is still there today until September 9, 2018." $Days. " Days ";? >
---------------------------------------------$arrayStartDate =explode ("/", $myStartDate); $arrayEndDate = Explode ("/", $myEndDate); $jdStartDate = Cal_to_jd (Cal_gregorian, $arrayStartDate [1], $arrayStartDate [ 0], $arrayStartDate [2]); $jdEndDate = Cal_to_jd (Cal_gregorian, $arrayEndDate [1], $arrayEndDate [0], $arrayEndDate [2]); $duration = $jdEndDate-$jdStartDate + 1;
Statistics that expire after a few days
DateDiff (Yxdate_star,now ())
Return days: Yxdate_star-now ()