Did you know that the default timezone for PHP is UTC, irrespective of your server’s timezone? This default setting is used by all PHP date and time functions in all your scripts. If you notice that the time in your PHP scripts is incorrect, it is because your hosting server is in a different timezone. You can rectify this situation by changing the PHP India timezone for an app by creating a user.ini file in the app’s public directory with the following contents:

Date.timezone = Asia/India 

You can check the PHP’s list of supported timezones to find the names of all possible options.

 

Steps to change Timezone in PHP

To change the set timezone option in PHP, you need to insert a line of code into your php.ini.file. The location that you set in the code will determine the time displayed in your PHP scripts.

  1. Log in to your Bluehost account
  2. Go to the cPanel

 

If you have a Bluerock account: 

  1. Go to the Advanced tab, click on the Files section and select Files Manager
  2. Open the public_html folder
  3. Go to the folder that contains the .htaccess file and click on the Edit button Or you can right click on the selected files and click on Edit from the drop-down menu
  4. Press Ctrl+F to find the section and enter the <IfModule lsapi_module>
  5. Add this line php-value date.timezone. “America/Denver”

change timezone in php

Replace the timezone with the one that corresponds to the one you wish to display. Do not forget to save the changes made.

 

If you have a Legacy account,

  1. Log into your Bluehost cPanel
  2. Locate the File Manager under the Files category
  3. Choose to open Web Root and Show hidden files, then click the submit button
  4. Go to the folder containing the PHP.INI file
  5. Press Ctrl+F (Shortcut to find section easily) and enter the <IfModule lsapi_module>
  6. Add this line php_value date.timezone “America/Denver”

change timezone in php

  1. Change the location as per the timezone you wish to use
  2. Once done, click the Save Changes button towards the top right side of your screen

 

Now that you have changed the timezone in PHP, you can check the same by going to the phpinfo.php page.

Write A Comment