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.

Was this answer helpful?

Also Read

How to check your bandwidth usage in cPanel?

Bandwidth devices reads the traffic data that can be displayed in graph. Bandwidth usage is a sum...

How to disable mod_security

Issue: Having 403 error page when uploading files to your directory using your CMS application...

Files fail FTP transfer

When uploading many files at once (a CMS, for example), it is not uncommon for a few of the files...

Turn On/Off Directory Browsing

For Linux server: Turn on Directory Browsing -create a .htaccess file in the specific directory...

I've updated my website, but still see the old version. What's going on?

You must Refresh your browser. Your computer holds a copy of your website in 'cache'. Things to...