I have this entry in php.ini file:
date.timezone = 'Europe/London';
But every time I use DateTime () in a command line script, I still get the following error:
Exception: DateTime::__construct(): It is not safe to rely on the system 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
So I have to do the following in any scripts to get this to work:
date_default_timezone_set('Europe/London');
What else could cause this error?
UPDATE
On the command line and in a web browser, I used the following:
<?php var_dump(ini_get('date.timezone')); exit;
At the command prompt, I get:
string(0) ""
In a web browser, I get:
string(13) "Europe/London"
php
user1572427
source share