It is necessary to compare the current time with the set one, if the current time is more than the set one by at least 30 minutes, then output the phrase. I get this error Call to a member function format () on boolean. Tell me where I'm wrong
$datetime1 = new DateTime(); $datetime2 = date($DB->DateFormatToPHP(CSite::GetDateFormat("FULL")), time()); // выводит дату в формате сайта 08.09.2017 10:17:57 $interval = $datetime1->diff($datetime2); $m = $interval->format('%i'); $h = $interval->format('%h'); if($m > 30 || $h > 1){ echo "time"; }
type 2 -- DateTime::diff() expects parameter 1 to be DateTimeInterface, string givenbecause you give the parameter a string, but you need DateTime - Alexey Shimansky