ApacheWeb Server

[How To] Change or update Apache time zone

If websites are hosted on shared servers and timezone is different, one may demand to change the timezone for his/her website.

In this case, there is no need to change the timezone on the server. We can change the timezone for the particular website using following methods.

The Apache time zone can be updated in two ways:

1) Using PHP configuration file php.ini

2) Using .htaccess file

Let us see each of them in detail:

Updating time zone using php.ini file

1) Check the global php,ini file location on the server

php -i | grep php.ini

2) Open php.ini for editing

vi php.ini

3) Search for "date.timezone"

4) Update the time zone

date.timezone="Asia/Kolkata"

Refer PHP supported timezone here.

5) Save the file

6) Restart Apache service

Note: Custom php.ini can be used instead of editing global php.ini on the server.

Updating time zone using .htaccess

1) Open .htaccess file present under the document root. If not present already, then create a new file.

2) Add line

SetEnv TZ timezone

where timezone is the timezone you wish to set.

Refer PHP supported timezones here.

3) Save the file

Hope this helps!

Abhijit Sandhan

Love to Automate, Blog, Travel, Hike & spread Knowledge!

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

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

Back to top button