PHP is now much matured programming language to create fast and efficient web applications. Many big companies and their portals are developed making core base of PHP language. It is becoming choice for many web developers in the industry and satisfying their clients delivering PHP based software.
Most of developers find web development with PHP very easy compare to other programming languages. But with the development, it is also important that we understand few configurable PHP directives which cause warnings and notices while development.
When we create a platform to deploy and run the PHP source code with Apache web server, it is commonly found to many startup developers the warning of setting up a proper time zone. The warning says “It is not safe to rely on the system's timezone settings”. This means your PHP configuration is not instructed specifically which Time Zone to follow while running any time/period based operations developed or coded in the application. It is referring the operating system’s time zone value from the system’s clock and this may not be the good idea every time.
Then, how to resolve it? Two very well known ways experts follow.
If you have an access of your PHP installation, then open the php.ini file. Go to the line where the directive “date.timezon” is written under the [Date] block. Specify the timezone value there. i.e. in php.ini installation it is displayed as
date.timezone = "America/Los_Angeles".
Save the file and do not forget to restart the apache web server.
If you do not have the access of your PHP installation, then use the PHP function to set the time zone to the application.
date_default_timezone_set('America/Los_Angeles');
write this function in the top of the file which is included in all requests like include.php, core.php or may be common.php whatever name is there.
Hope this will help to resolve one of the common warnings generated by the PHP installation. I am going to list few more which will allow new developers to identify the cause of such warnings. Comment this article with your views or anything you need specific about this Time Zone directive.
1 Comment