[Solved] Warning: date() on PHP

12:13 AM

Today i getting error when running my site on localhost. I got this error for date function with php.
Warning: 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.
I think, this is happen when i don't set the date timezone function on php. But don worry about it, because i know the solution based on stackoverflow answer. You just need to adding some change on php.ini files on your pc / computer

I am using ubuntu with apache2 server. So i start open the php ini file with gedit using this command
gksudo gedit /etc/php5/apache2/php.ini

The terminal command below will using gedit for opening the php.ini files.

Search for date.timezone

After opening the php.ini file, let search for date.timezone on the document. I am using find feature on gedit to get it. It was simple, because you can only found one date.timezone on php.ini files.

Change date.timezone
Change date.timezone on php.ini

Just delete the command and set the date.timezone for your location. You can use php manual to knowing what timezone that match with your location.

After change and save the php.ini files, you need to restart apache to get this function reloaded using

sudo /etc/init.d/apache2 restart 


So, your command on terminal will looks like this

Restart Apache2 on Ubuntu
Restart Apache2 on Ubuntu
After restarting the apache server, please reload your site and tara.... error for function date is gone. So i think the problem with php date is solved!

For some reason i can't update this blog with long article, i think last year i will trying to write great content for this panduaji.com blog, not only the part of tutorial like this. Good luck for your php project ;)

You Might Also Like

0 comments

Popular Posts

Subscribe