Warning: strtotime(): It is not safe to rely on the system’s timezone settings in CakePHP SOLVED

If you are trying to run the CakePHP console from your command line, probably you are obtaining a warning related with the system’s timezone, that is a normal behavior if your web server doesn’t have a timezone configured correctly. Let’s see an example about this and how to solve it.

Cake-logo

Problem

Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /Applications/XAMPP/xamppfiles/htdocs/projects/juan-nuevo/lib/Cake/Cache/CacheEngine.php on line 60

Solution

  • Go to the core.php file in your CakePHP project, something like this: YOUR_SITE/app/Config/core.php
  • Search for next line:
// date_default_timezone_set('UTC');
  • Once you find the line, uncomment  it and set your timezone, for example in my case I am going to use “America/Mexico_City”. Find more information about timezones in this link: https://php.net/manual/en/timezones.php
date_default_timezone_set('America/Mexico_City');

That’s it!

Be happy with your code!

Leave a Reply

Your email address will not be published. Required fields are marked *