I'm trying to compare two different new DateTime
by minutes but I have no luck with it!
one is the end date which is in the future and the other one is the end date + 10 minutes.
so when the end date is smaller than the one with 10 minutes added, i need to do something and if the end date is still greater than the one with 10 minutes added, i need to run my code as usual.
my current code is this:
$end_date = new DateTime('2015-01-21 17:28:23');
$datetime1 = new DateTime();
$datetime2 = new DateTime($end_date);
$interval = $datetime1->diff($datetime2);
$finalDate = $interval->format('%d day %h hours %i minutes %s seconds');
$minutes_to_add = 10;
$time = new DateTime($end_date);
$time->add(new DateInterval('PT' . $minutes_to_add . 'M'));
echo $stamp = $time->format('Y-m-d H:i:s');
echo '<br />';
echo $stamp = $datetime2->format('Y-m-d H:i:s');
if( $time->format('Y-m-d H:i:s') < $datetime2->format('Y-m-d H:i:s')){
echo("result_messageTi=times up");
}
}
}else{
echo("result_messageTi=$finalDate");
}
the code above does not compare the two given times at all and in result i get nothing on my php page.
could someone please advise on this?
Thanks in advance.