function days_between($date1, $date2) {
$date1 = strtotime($date1);
$date2 = strtotime($date2);
return ceil(abs($date1 - $date2) / 86400 + 1);
}
echo days_between('2005-01-02', '2005-05-05');
86400 = 60 60 24 = seconds per day
- 1 to count the first day as well