Have you every wondered why the time on your web host didn’t match your local time? It wasn’t something I had thought about much before, until I was running a particular php script on my web host. I was looking at the time it was displaying and I realized to my annoyance, that it wasn’t set to my timezone.
If you are on a VPS (or dedicated server), changing the time zone is quite simple if you have cPanel/WHM. Just login, and go to Server Configuration > Server Time.
On that page, you will see a dropdown where you can select your timezone. Click the ‘Change Timezone’ button and your selected timezone will be selected for your server.
What about setting your timezone for shared hosting? Unfortunately, you can’t do this through cPanel/WHM like you can with a VPS. Since many other people are sharing your server, it doesn’t make sense to allow people to change the timezone for the server.
What you can do however is add a directive to the .htaccess file in your ~/public_html directory. This will allow your scripts and webpages to use the proper time.
Using FTP or SSH, open up ~/public_html/.htaccess (or create a new file if it doesn’t exist) and add the following line:
SetEnv TZ America/Los_Angeles
You can replace the bolded part with your appropriate time zone by looking here:
Now you know how to change the timezone for your web host. I hope some of you found it useful.