Calculate number of days between two given dates using PHP using strtotime?

The strtotime php function is used to parse any English textual datetime description into a Unix timestamp. This function will use the TZ environment variable (if available) to calculate the timestamp. It returns a timestamp on success, FALSE otherwise. Previous to PHP 5.1.0, this function would return -1 on failure.

$date1 = date(‘Y-m-d’);
$date2 =2005-03-01;
$days = (strtotime()strtotime()) / (60 * 60 * 24);
echo “Number of days since ‘2005-03-01: $days”;

Tags:
One Comment

Leave a Reply