Storing Dates and Timezones

i’m located in EST, but the server is PDT. i’m saving the date/time as a unix timestamp (time()) and using a format of date(“D, F jS g:i A T”, $post->DateCreated), which has an output that looks like this: Thu, June 10th 6:55 AM PDT.

since i’m EST, i’d like it to read Thu, June 10th 9:55 AM EST.

my first thought is to simply add 3 hours to the timestamp and not use “T” in the format and just put “EST” in it’s place…but i wanted to check with you all to see if there was a way where i could change the timezone “on the fly” with this timestamp.

Np, taht is server time…
unless u know a way to create a custom command fot HTTP settings file, then it might work if your ISP will give you those permissions

i actually figured out a pretty sweet way to do this…

[php]function showtime($theformat) {
if ($_SESSION[“user_timezone”]) { //user has specific timezone
$thedate = gmdate($theformat, time() + (3600 * $_SESSION[“user_timezone”]));
} else { //user doesn’t have a specific timezone
$thedate = date($theformat);
}
return $thedate;
}

//usage
print showtime(“m/d/y h:i:m”); //or whatever format you want[/php]

:o
Sponsor our Newsletter | Privacy Policy | Terms of Service