Sun

How to change PHP date.timezone using .htaccess file?

  1. Home
  2. Knowledge Base
  3. How to change PHP date.timezone using .htaccess file?

How to change PHP date.timezone using .htaccess file?

This tutorial will show how to change PHP date.timezone on your site by using .htaccess file.

  1. Connect to your cPanel and go to File Manager.
  2. Then, go to public_html (or your website folder) and find .htaccess file. If you cannot find your .htaccess file, you can follow this guide.
  3. Then right-click on the file and select Edit.
  4. Enter the following code at the very top of your .htaccess code:
    php_value date.timezone 'country/state'
  5.  You can find time zones here.
  6. After adding your wanted zone, click Save Changes when you’re done.

How to check if changes are visible? 

To check if the changes are visible and correct, you should follow these steps:

  1. Create a new phpinfo.php file on public_html directory or on your website folder.
  2. Then paste this code: 
    <?php

    // Show all information, defaults to INFO_ALL

    phpinfo();

    ?>
  3. Then, click on Save Changes.
  4. Open a new browser tab, go to your site, but add /phpinfo.php. It should look something like this:

yourdomainname.com/phpinfo.php

Scroll down to find the date.timezone information table.

 

Was this article helpful?

Need Support?

Can't find the answer you're looking for?
Contact Support