Im wondering how to go about adding a timezone setting for users to my site, currently an example time showed on my site is this
2007-08-07 07:44:54
I would like someone on Eastern standerd time -5 be able to pick this as an option and adjust time time sitewide, any insight on how to do this the most efficient way for a very hight traffic site
store the timezone in a session variable as a simple integer (+ or - depending on which side of greenwhich they are) then just add/substract from your timestamps.
Thats what I was thinking but thanks for clarifying
So 1 example on my site I have
<?=$line_announcement['submitdate']?>
which shows
2007-08-02 09:21:27
hiw would I -5 for example from that?
i suggest that you store all of the dates/times as GMT then do something like:
$gmt = '2007-08-02 09:21:27'; echo date('Y-m-d H:i:s', strtotime($gmt) - (5 * (60 * 60)));
$gmt = '2007-08-02 09:21:27'; echo date('Y-m-d H:i:s', strtotime($gmt) - ($timezonesetting * (60 * 60)));
so would this be correct to have there timezone setting in place? and - value would work to like -6 (60 60) ?
a simple example:
function tz_adjust($gmt, $offset) { $date = date('Y-m-d H:i:s', strtotime($gmt) + ($offset * 3600)); return $date; } $gmt = '2007-08-02 12:00:00'; echo tz_adjust($gmt, -5) . '<br>'; echo tz_adjust($gmt, 7) . '<br>';
thank you