Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP DateTime throws timezone warning even though date.timezone set

Tags:

php

I am constantly getting the following error :

DateTime::createFromFormat(): 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

Although I've specified the DateTime settings in my php.ini like this:

date.timezone = Asia/Jakarta

Any idea?

like image 450
adit Avatar asked Nov 19 '13 02:11

adit


2 Answers

You're just missing some quotes.

date.timezone = "Asia/Jakarta"

Best of luck!

It could also be that you are not loading the correct php.ini file. See this post for more info: php5.3.3 date.timezone again php.ini directive not taken into account

like image 129
zacatac Avatar answered Oct 19 '22 21:10

zacatac


You can use

date_default_timezone_set("Asia/Jakarta")

at the beginning of your script

like image 23
Guillermo Mansilla Avatar answered Oct 19 '22 20:10

Guillermo Mansilla