ALL SYSTEMS OPERATIONALUPTIME 99.97%FLEET 18/18IN-MUM · US-LAX · EU-FSN EST. 2003 · +91 11 4998 4038

KNOWLEDGEBASE · PHP

How to change timezone in PHP scripts?

Last updated 2020-04-05

If you only want particular PHP scripts (not a cgi scripts) to use a specific timezone, set the timezone environmental variable in your PHP code like so:

<?
echo "Original Time: ". date("h:i:s")."\n";
putenv("TZ=US/Eastern");
echo "New Time: ". date("h:i:s")."\n";
?>



If you put the line putenv("TZ=US/Eastern"); in a file that is
include()'ed by all your other PHP scripts, then all your PHP scripts will use that timezone.

A list of timezones to choose from, other than "US/Eastern" for your putenv() is here:

http://www.theprojects.org/dev/zone.txt

← All knowledgebase articles

Tell us what has to stay up.

A short conversation with an engineer. No quote-bot, no callback queue. We'll tell you honestly if we're not the right fit.