PHP 5.1+ Date vs Strftime Timezone Annoyance
In the old PHP4 days, you could change the default timezone by: putenv("TZ=America/Los_Angeles");. In php5, you can still do this and it’ll work for strtotime, strftime, gmstftime (maybe more). It will not work for methods date and gmdate. For those, starting in version 5.1, you’ll need to call date_default_timezone_set("America/Los_Angeles");. This is just another one of those annoying things that make PHP a dying language.
Together, to be cross-version compliant:
putenv("TZ=America/Los_Angeles"); if( function_exists("date_default_timezone_set") ) { date_default_timezone_set("America/Los_Angeles"); }
We need both to be reverse-compatible with PHP4.