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”;
Ashesh

सयौ थुङ्गा फूलका हामी एउटै माला नेपाली, Welcome to my webpage. I'm from the Himalayan Country of Nepal. Well talking about me, I like mostly Web programming and Designing and furthermore I like Philosophical literature, Photography, Social networking. And I am Romantic and Sentimental person to some extent. Read more...

View Comments