Posts Tagged ‘dateinterval’
January 12, 2011 Leave a comment
You have two dates and you want to know the difference between them in days.
$datetime1 = new DateTime('20110107'); # ... = new DateTime('2011-01-07'); is also good format $datetime2 = new DateTime('20110110'); $interval = $datetime1->diff($datetime2); print $interval->days; # 3
I found this elegant solution in this thread.
How old are you (in days)?