Compare Dates (UTC with Local)


I have got a problem comparing two dates:

First date (see debug upper) is the output of Time::now();
Second date (see debug lower) is the output of a database field.

Now if i check, if the second date “->isPast()” it returns false. I think this happens because of the time difference between UTC and Europe/Vienna (+02:00 i guess?).

I tried to set the timezone at the datasource setting -> “+02:00”, but it makes no difference.

Any suggestions to fix this?



To make the camparison I would take the euro/vienna timestamp convert it to UTC and then compare. Does that help? Not sure what you mean by at “datasource”


well, actually both are Europe/Vienna Timestamps … if i’d convert the first to UTC, the time would be 09:14:29 … i just want to compare 11:14:29 and 10:50.05 … but it wont work :sweat:


any one else an idea?


try to set cake to work with your locale/timezone:

in config/app.php:
    'App' => [
                'defaultLocale' => env('APP_DEFAULT_LOCALE', 'UR-LOCALE-CODE')

in config/bootstrap.php:



now both dates should be in the same timezone and you may proced the compare