Powered by coANDco UK

Editing How to fix the date error in CakePHP

From How2s

You might have an initial error saying something like the below in CakePHP:

Warning: date() [function.date]: 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 'Europe/London' for 'BST/1.0/DST' instead in /Library/...../cake/libs/cake_log.php on line 94 

Warning: strtotime() [function.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 'Europe/London' for 'BST/1.0/DST' instead in /...../cake/libs/cache.php on line 429 

Warning: strtotime() [function.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 'Europe/London' for 'BST/1.0/DST' instead in /...../cake/libs/cache.php on line 429

Warning: strtotime() [function.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 'Europe/London' for 'BST/1.0/DST' instead in /...../cake/libs/cache.php on line 429

To fix this, follow the below steps:

  • open the file ./app/config/bootstrap.php
  • at the bottom before //EOF add the line *Configure::load('config');* . This tells CakePHP to include a new configuration file called config.php in the same directory.
  • create the file *config.php* in ./app/config/
  • add the code:
<?php

$config = array(
  'App.name' => ' ',
  'App.guestAccount' => ' ',
  'App.feedbackEmail' => ' ',
  'App.loginCookieLife' => '+1 year',
  // any arbitrary config line
);

date_default_timezone_set('UTC');

?>

If you're also having the "Deprecated" error, you might be interested into fixing that as well under How to resolve the "Deprecated" error in CakePHP

Please check out our sponsor, thanks to whom How2s.org is FREE: