This article describes the example of PHP using strtotime to calculate the number of days between two given dates. . Share it with everyone for your reference. The specific analysis is as follows:
PHP’s strtotime function is used to parse the date-time description of any English text into a Unix timestamp. This function will use the TZ environment variable (if available) to calculate the timestamp. It returns a timestamp if the execution is successful, otherwise it returns FALSE. Prior to PHP 5.1.0, this function would return -1.
$date1 = date('Y-m-d'); $date2 = '2005-03-01′; $days = (strtotime() – strtotime()) / (60 * 60 * 24); echo "Number of days since '2005-03-01′: $days";
I hope this article will be helpful to everyone’s PHP programming design.