Skip to content

Instantly share code, notes, and snippets.

@stefanocudini
Created March 25, 2012 00:54
Show Gist options
  • Save stefanocudini/2190479 to your computer and use it in GitHub Desktop.
Save stefanocudini/2190479 to your computer and use it in GitHub Desktop.
convert time from utc to locale timezone
<?
//convert time from utc to locale timezone
$tz = getenv('TZ'); // Get current server time zone setting
echo "Current timezone setting: $tz <br>";
putenv("TZ=EST5EDT"); // Change to US Eastern time zone or whatever you want
$lt = localtime(time(), TRUE);
echo "EST local time: ".$lt['tm_hour'].':'.$lt['tm_min'].':'.$lt['tm_sec']." <br>";
putenv("TZ=$tz"); // Change it back to the original server time zone
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment