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?
You can use
date_default_timezone_set("Asia/Jakarta")
at the beginning of your script
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
Maybe this process running in php cli so, you need put this configuration inside your CLI php.ini in the following path: /etc/php5/cli/php.ini
By default the "date.timezone" was commented, so change this config: date.timezone = Asia/Jakarta
For those who are having the same problem in Symfony 3 add the following constructor into your app/AppKernel.php file and restart nginx.
public function __construct($environment, $debug)
{
date_default_timezone_set('Asia/Jakarta');
parent::__construct($environment, $debug);
}
I also have specified the DateTime settings in my php.ini. In my case, the php.ini I edited was on
/Applications/MAMP/bin/php/php7.1.1/conf/php.ini
since I saw the path from info.php (in "Loaded Configuration File") that I generated on localhost.
Turns out it is not the one used. Try this instead:
php -i | grep php.ini
And see what the output is. Mine was:
/usr/local/etc/php/5.6
Loaded Configuration File => /usr/local/etc/php/5.6/php.ini
PHP Warning: Unknown: 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 Unknown on line 0
And then I just go to "/usr/local/etc/php/5.6" and edited the date.timezone line: removing comment (;) and added "Europe/Berlin" (or in your case "Asia/Jakarta".)
Try "php -i | grep php.ini" once again and the php warning message should be gone by now.
php -i | grep php.ini
Configuration File (php.ini) Path => /usr/local/etc/php/5.6
Loaded Configuration File => /usr/local/etc/php/5.6/php.ini
Still not working with the above solutions, try to add the following code in .htaccess of your root directory and check.
php_value date.timezone America/Denver