PHP calculates the number of days for date difference instance analysis and number of days for instance analysis. Example of calculating the number of days of a date difference in PHP. This article is for your reference. The details are as follows: analysis of the number of days of calculation difference between PHP and PHP today, and analysis of the number of days of calculation.
This article describes how to calculate the number of days for date difference in PHP. We will share this with you for your reference. The details are as follows:
<? PHP // how many days are there today different from January 1, October 27, 2016 $ Date_1 = date ("Y-m-d"); $ Date_2 = "2016-10-27"; $ d1 = strtotime ($ Date_1 ); $ d2 = strtotime ($ Date_2); $ Days = round ($ d1-$ d2)/3600/24); echo "today is different from October 27, 2016 ". $ Days. "Day"; echo"
"; // How many days are there between today and January 1, September 9, 2018 $ Date_1 = date (" Y-m-d "); $ Date_2 =" 2018-09-09 "; $ d1 = strtotime ($ Date_1 ); $ d2 = strtotime ($ Date_2); $ Days = round ($ d2-$ d1)/3600/24); echo "today to September 9, 2018 ". $ Days. "Day";?>
//---------------------------------------------$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;
Count the expired data in a few days
datediff(yxdate_star,now())
Returned days: yxdate_star-now ()