Paolo Bergantino
Paolo Bergantino

Reputation: 488704

Changing timezone in PHP

Alright, quick question.

A server is running in Eastern Time. PHP program needs to make date calculations using Central time.

At the moment, I am putting this line at the very top of my script:

putenv("TZ=US/Central");

Is that the best way to go about that or is there some PHP trick I'm not aware of?

Cheers.

Upvotes: 3

Views: 592

Answers (1)

Christian C. Salvadó
Christian C. Salvadó

Reputation: 828002

You can use date_default_timezone_set and all the date/time functions in the script will use it.

Upvotes: 5

Related Questions