PHP datetime comparing days
date, datetime, php
Solution
You should be able to use:
$interval->days;
See: http://www.php.net/manual/en/class.dateinterval.php#dateinterval.props.days
echo "There are ".$interval->days." days between the two dates.";
Problem
I'm comparing dates with this code: ``` $date1 = new DateTime("2007-03-24 12:10:00"); $date2 = new DateTime("2009-06-26 14:00:30"); $interval = $date1->diff($date2); ``` If I echo this: `echo $interval->m." months and".$interval->d." days.";` I get the output `3 months and 2 days.`. Now, I want to echo the difference between the dates but include the amount of months in the day count, so a difference of 1 month (with 30 days in it) and 5 days would be 35 days, not 1 month and 5 days. How do I do this? I'm using PHP version 5.3+.