Knowledge Base

Get Expert Website Hosting

Choose website reliability and expertise with SiteGround!

Home / Website Help / PHP Questions / How to change the timezone for a single PHP file?

How to change the timezone for a single PHP file?

Last update: Nov 11, 2021

To set a specific timezone for a PHP script, use the following function which should be added to the PHP file:

putenv("TZ=US/Central");

This is just an example. The full list of supported timezones is available here. Replace “US/Central” with the desired timezone.

To change the PHP timezone per-folder, check this article for information on how to do it.

Share this article