RE: [PHP] strtotime time zone trouble

From: Date: Tue, 18 Jan 2005 16:57:32 +0000
Subject: RE: [PHP] strtotime time zone trouble
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-206660@lists.php.net to get a copy of this message
Marcus Bointon wrote: > Much of the point of using zone names rather than fixed numeric > offsets is that it allows for correct daylight savings calculations > (assuming that locale data is correct on the server). > > Let me rephrase the question - how can I get the current time in a > named time zone using strtotime and without using a numeric offset? This may not be the cleanest way to approach it, but this is what I use and it Works For Me(TM): $timeZoneMap = array( 'EST5EDT' => 'Eastern Time', 'CST6CDT' => 'Central Time', 'MST7MDT' => 'Mountain Time', 'PST8PDT' => 'Pacific Time' ); $currentTime = time(); foreach ($timeZoneMap as $envVar => $timeZone) { putenv("TZ=$envVar"); print "The current time in $timeZone is "; print strftime('%m/%d/%Y %I:%M:%S %p %Z', $currentTime)."\n"; } HTH

« previous php.general (#206660) next »