View Full Version : GMDATE Revisited
MonsterMan
04-24-1999, 11:46 AM
I'm sure you all are probably tired of this conversation... But here's a generic question.
I'm building a server-based applicatoion that, with luck, people from various time-zones will be usnig.
How do I let the user pick their time zone and have the application show the correct time for them?
Can someone direct me to references elsewhere on the 'net that may have CODE SNIPPETS that I could swipe?
I'm thinking about having users select a timezone and then storing it in a profile for each user so I have it available when they log in...
Thanks for any ideas....
Justin
04-24-1999, 03:25 PM
This is just a cheap idea, but it does work (URL's below):
[Ucode]
<?
# if they wish to set their time zone offset
if ($set) {
# set it to a cookie expiring in one year
setcookie("tzo",$NewTzo,time + 31536000);
# also set new timezone to variable
$tzo = $NewTzo;
}
# If no cookie set, time zone offset = 0
if (!$tzo) {
$tzo = 0;
}
$TheTime = (time() + $tzo);
echo gmdate("M d Y H:i:s",$TheTime);
if ($tzo == -7200) {
$S1 = "selected";
} elseif ($tzo == -3600) {
$S2 = "selected";
} elseif ($tzo == 0) {
$S3 = "selected";
} elseif ($tzo == 3600) {
$S4 = "selected";
} elseif ($tzo == 7200) {
$S5 = "selected";
}
print "
<html>
<body>
<form action=gmtest.php method=post>
Time zone offset: GMT
<select name=NewTzo>
<option $S1 value=-7200>- 2:00
<option $S2 value=-3600>- 1:00
<option $S3 value=0>0
<option $S4 value=3600>+ 1:00
<option $S5 value=7200>+ 2:00
</select>
<input type=submit name=set value='Set my Offset'>
</form>
Notice that it saves your offset in a cookie
so you never have to set it again. If you do
it will remember the new offset. This cookie
stays for 1 year. Thank you for visiting my
cheap demonstration http://www.aota.net/ubb/smile.gif
</body>
</html>";
exit;
?>
[/quote]
Or you can see this in action at www.vdj.net/gmtest.php (http://www.vdj.net/gmtest.php) , or view it's source at www.vdj.net/gmtest.phps (http://www.vdj.net/gmtest.phps) .
Hope this helps...
------------------
Justin Nelson
FutureQuest Support
[This message has been edited by Justin (edited 04-24-99).]
MonsterMan
04-24-1999, 10:22 PM
Thanks Justin -
I think I can adapt this for my needs. Appreciate your help!
Thanks again,
M-Man
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.