htaccess

How to Change Timezone Using .htaccess

If you have noticed that time on your website is not what you would expect and want to change it, there are several options. Most shared hosting providers are restricting access to php.ini file, but you can still change the timezone on your website using the .htaccess file.

What you’ll need

Before you begin this guide you’ll need the following:

  • Access to hosting control panel or FTP account

Step 1 — Opening up your .htaccess file.

.htaccess file is located in your public_html directory. You can open it up using File Manager in your hosting account’s control panel or by connecting to your account via FTP Client (FileZilla, for example). The following tutorials describe both methods in detail:

Step 2 — Finding the correct timezone

You can check a list of all supported time zones at this website.

List of regions

Firstly select your region.

List of timzeones

Now select a timezone that you want to be used on your website. In our example, we have chosen America/Chicago.

Step 3 — Setting timezone via .htaccess file

Once you know what format your timezone should be in, navigate to your .htaccess file. After that, enter the following code at the very top of your .htaccess code:

php_value date.timezone 'America/Chicago'

IMPORTANT! Instead of America/Chicago, you would need to use your chosen timezone.

After the timezone code is entered, don’t forget to Save the changes you have made.

Saving time zone changes in htaccess using File Manager

Congratulations, you have successfully changed the time zone of your website!

Conclusion

This quick tutorial shows how to change the default time zone on your website with the help of .htaccess file.

About the author

Elvinas S.

Elvinas is a senior server administrator at Hostinger. He monitors the infrastructure’s well-being and keeps the uptime at a maximum. Besides server management, web development has always been one of his biggest passions.

Add Comment

Click here to post a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Get Exclusive Content

Join thousands of webmasters who get our free newsletter with tips on how to drive more traffic and revenue to their websites!

Please wait...

Thank you for sign up!

More in htaccess
How to Allow or Block Visitors From Specific Countries Using .htaccess
Close