Page 1 of 1
determine timezone (with daylight savings)
Posted: Tue Apr 05, 2005 6:11 pm
by Burrito
I am setting up an event scheduler and when my users create an account, they select their timezone, I want to be able to send reminder emails about upcoming events with the time they need to log in to the event (their correct time (given their zone)). My problem is, I'm in AZ and we don't do daylight savings here so I can't just do +1, +2, +3, -1 for the hours for the timezone they've selected as it will be different depending on whether or not you all are on ST or DT. Is there some way I could determine whether it's daylight or standard time dynamically? Is there a calendar function built in that has these dates for say...15 years into the future? Has someone built one they'd be willing to share? Is there another way to make this determination?
please advise,
thx,
Burriskimo
Posted: Tue Apr 05, 2005 6:23 pm
by feyd
generate a GMT timestamp (safest) .. I believe the locale settings will adjust accordingly, or if you look down the page a bit... there was a reference to worldtimeserver.com I believe..
Posted: Tue Apr 05, 2005 6:29 pm
by Burrito
ok so if I generate a timestamp, won't that be for MY server (since I'm doing this all server side)? How could I then adjust the time according to the setting they've chosen when they registered?
Posted: Tue Apr 05, 2005 6:40 pm
by feyd
If you make a GMT timestamp, it'll be adjusted from your server's locale settings to GMT. From there, you can conver to someone else's timezone relatively easy.
In the past, I've done a little Javascript (with graceful fallback) that determined the timezone of the machine viewing the server, which is sent to the server through an image query, or some other form you can decide. A checkbox is placed in the user settings if Javascript is enabled in their browser. Otherwise, they are considered to not observe daylight savings..