I am getting datetime
from the user through a form and the datetime entered by him, should be greater than current instance of time to be valid.
I am trying something like this
$input_format = 'd M Y - h:i a';
$date = DateTime::createFromFormat($input_format, $_POST['delivery_time']);
$now = new DateTime();
if(!$date || ($date->diff($now) > 0))
{
$error .= '* Invalid Delivery Day/Time';
error_log('WARNING :: Invalid Delivery Time at LINE: '.__LINE__.' in '.__FILE__.'
',3,$logfile);
}
I am having problem in the comparison.I get Object of class DateInterval could not be converted to int
as error. What is the correct method to ensure that the entered time is greater than correct instance of time