Knowledgebase

How can I change my default PHP timezone?

Issue:

Why my application keep showing UTC time? this has cause my application not to log the correct time when the function being executed.

Reason:

This issue are cause by the PHP default timezone. By default, all our servers which is running PHP will used default PHP time zone, which is UTC. You can verify this by running a phpinfo() function inside your php file. You will see the output of the default timezone used by PHP under date directives.

date.timezone UTC UTC

Solutions:

To set your preffered timezone, you will need to do below steps:

  1. Login to your cPanel account.
  2. Access File Manager and open public_html folder.
  3. Create a php.ini file and fill it with below variable:
    date.timezone = "Asia/Kuala_Lumpur"

    You may change "Asia/Kuala_Lumpur" with your preffered timezon base on this link: PHP TimeZone

  4. Now edit your .htaccess file and add below lines:
    <IfModule mod_suphp.c>
    suPHP_ConfigPath /home/username/public_html/php.ini
    </IfModule>
  5. Save and check your date setting now.
  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

Common SEO Tips and Tricks

Include a title tag on all of your pages. Include a meta description tag on your homepage...

Page is displaying 404 Page Not Found error

The 404 Page Not Found error means that the user requested a page on the server that does not...

How to redirect user from none www to www.domain?

Scenario: You want to force all users/client to access your website using https instead of http....

How to manage git version control ?

  How to Create a Git Repository with cPanel   Step 1 : Login to cPanel account Step 2 :...

PHP failed to include file: File Not Found

The PHP include() File Not Found error will occur when a .php file attempts to include another...