[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!

Share on Facebook0
Share on Google+4Tweet about this on TwitterShare on StumbleUpon0Share on LinkedIn0Share on Tumblr0Digg thisPin on Pinterest0Share on Reddit0Email this to someonePrint this page
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…

Review Overview

User Rating: 4.9 ( 2 votes)

About Abhijit Sandhan

Abhijit Sandhan
Loves Linux, Blogging, Traveling, Hiking and sharing knowledge!

Leave a Reply

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

CAPTCHA