I don't know, maybe there's a way .net knows these things?
Main Topics
Browse All TopicsHi experty experts,
I'm using GMT time to store calendar events in a database. Here's my question, if someone puts in a date and time, how do I tell if it's in daylight savings or not?
At the moment I'm using an array with all the different time zones in it (+ or - the hours). But I'm guessing there's a better way.
Thanks in advance.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
If someone enters the value on a local PC, you could get DateTime.Now and check the value of IsDaylightSavingsTime. If they are entering values on the Web from possibly different time zones, you won't know unless you ask (or have some background check).
The better way to track time like this would be to store the UTC time which is the basis for the DateTime class. The you can convert it to local time (including DST), perform operations, etc.
It's not clear what you are doing with the array of time zones. Please explain if I haven't answered your question already.
<<It's not clear what you are doing with the array of time zones.>>
I'm adding or subracting based on PST, EST and 50 other time codes.
Let's say for example it's daylight savings tomorrow in the time zone and a person says "send me an alert at 10:00am tomorrow", I add the time difference based on the current time difference, but tomorrow the time difference is different.
How can I tell the daylight savings time of the time the person want's the alert.
Like if they want monthly alerts or weekly alerts, the time in the database has to be changed when the time changes.
Is there a way to make that more effecient, and how do I tell when daylight savings time changes for every time zone?
This depends on how the alert is activated. I would guess there is a background thread running for each client that compares the desired date/time of the alert to the current local time.
You might find this article interesting:
http://msdn.microsoft.com/
Using the TimeZoneInfo objects plus the classes DateTime and TimeZone, you should be able to get where you want to go, but again I question how this is implemented.
Thanks Deric, that will give me the time zone at that time, but what if the time changes?
What I'm doing is using a global timer, because users most likely won't be logged in to the web site when the timer is due to be activated.
I'm just calling all times greater than the current time from the database.
If the timer is periodical, then it resets the time for that client.
OK, got it. So I imagine your app should do something like this:
for every "tick" of the clock
for each alarm in queued alarms
convert current UTC time to the time zone for this alarm
if current time in new time zone is past alarm time
send alert
The third line is probably the question. Take a look here
http://msdn.microsoft.com/
Note this only works with .NET Framework 3.5 or later.
I guess if you really wanted to implement that way, you could use TimeZoneInfo.ConvertTimeTo
Business Accounts
Answer for Membership
by: sybePosted on 2009-10-31 at 07:18:49ID: 25709898
> if someone puts in a date and time, how do I tell if it's in daylight savings or not?
How could you know without asking?