I'm gonna need to set up same date comparisons and I'm practicing first with this php code, however no matter how I alter the date I end up getting the hours and seconds but the minutes is always 0. Btw, ideally I would like to be able to write the date in the european format dd/mm/yy hh:mm
however this didn't work so I adjusted it to the US format. Anyway thanks for the help.
date_default_timezone_set('Europe/London');
$date= new DateTime('2015-06-21 18:32:00');
$now = new DateTime();
$interval = $date->diff($now);
echo "difference " . $interval->d . " days, " . $interval->h." hours, ".$interval->m." minutes";
You made a simple mistake with the property used to represent the intervals minutes, its
i
and notm
.m
is in fact the Months property.This is also how you would set the date using the European format
If you do a
print_r($interval)
you will get to see all the properties like this