I am running a web server in amazon aws and its running centos and has cpanel and whm installed (latest). The php scripts are running okay. However when I display date and time in php code I see incorrect time. The timezone for the server is correctly set (incl. date & time) but its incorrect in php ini setting.
PHP info shows loaded configuration file as /opt/cpanel/ea-php56/root/etc/php.ini. However when I edit this from whm the comment says “cPanel-generated php ini directives, do not edit” & “To make changes to this file, use the cPanel MultiPHP INI Editor”.
In cpanel multi php ini editor the system says “ini content does not exist. You may add new content.” So what to do ? If I set time zone setting in there then will system just read that setting from here or entire setting from here or what. Please help me as I am not familiar with linux environment.
2
Answers
Use date_default_timezone_set function like so:
you can use for time zone any valid tz, such as:
$tz = “Europe/London”;
$tz = “Europe/Prague”;
$tz = “Asia/Jerusalem”;
etc.
You can add this code to the begining of php.ini.
After adding the above code. You can check if the change happened using the
phpinfo(). If you set the server time then all the projects under that server will have that time zone unless you change it inside the project.
If you don’t have access to the php.ini in server you can do the edit by using the php function.
This will change the time zone to US/Central.