Post Category

How to get difference between two dates in days in php

<?php

$date1 = "2012-01-01"; //Old date
$date2 = "2012-01-10"; //New date

$diff = abs(strtotime($date2) - strtotime($date1));
$days = floor($diff / (24*60*60));
echo $days;

?>

Result: 9

Read 1208 times.

Comments:

Sipon Says: Thanks a lot. I am searching this script last 5 hours.

2012-11-05 04:51:14



Place Comment
Please write here your Comments/Feelings/Experiences/Suggestions/Feedback.
Name
Email
Comments