DateTime::__construct(): It is not safe to rely on the system’s timezone settings.
If your getting the above error, then you have a misconfiguration in your php.ini file, this is very easy to remedy. Firstly find out which php.ini file your setup is using, you can do this using phpinfo(), just echo that out on its own in a plain php test script, like so:
Then locate where it mentions what php.ini you are using (do a page search on the output), and then load that php.ini file up and look for the line that states:
it may be commented out like this ;date.timezone. Once you find it, set it to your region and capitol, as i have here:
date.timezone = ‘Europe/London’
And ensure that the semicolon is not at the beginning of this line. Save the file then restart your web servers Apache/PHP and the following error you saw should go away.
DateTime::__construct(): 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/Berlin' for 'CET/1.0/no DST' instead
6 thoughts on “DateTime::__construct(): It is not safe to rely on the system’s timezone settings.”
Thanks , a great tip.
Thanks you very much 🙂
Great. Fixed it.
It’s amazing in support of me to have a site, which is helpful in favor of my
know-how. thanks admin
my website Cara Setting WI-FI pada Laptop dan PC – Pedro,
This is great tip.
Not exactly sure this is such a great idea. With a basic LAMP stack, MySQL will write system time while php date values which will be inserted may be off. I’ve had these problems before and they aren’t fun. I’ve always ensured my date settings were commented out in my apache/php.ini’s. If your system is off, install the ‘npm’ package. Additionally, for production systems – be in the habit of setting the machine to UTC whenever possible