CakePHP 3.6:Cake \ I18n \ FrozenTime类的对象无法转换为int

I am trying to check if a date is later than a week ago in index.ctp:

(((!isset($task->date_end) || is_null($task->date_end))? 
        strotime('now') : $task->date_end) > strtotime('-1 week'))

But I receive this error:

Object of class Cake\I18n\FrozenTime could not be converted to int

To check if there is anything wrong with the dates in the database I changed them all to : 2019-01-02 05:06:00.000000

When you compare a non-integer to an integer, PHP's type juggling will try to convert the former to an integer, and FrozenTime objects cannot be converted to integers.

You can avoid this fragile construct by using date objects all the way, and use the comparison methods provided by them, for example.

$result = true;
if ($task->date_end !== null) {
    $lastWeek = \Cake\I18n\Time::now()->subWeek(1);
    $result = $task->date_end->gt($lastWeek);
}

See also