Click here to Skip to main content
15,881,715 members
Please Sign up or sign in to vote.
1.67/5 (2 votes)
See more:
On my site I have a clock that displays US time.
Is there a simple way to change from summer time to winter time
or I have to change my code every winter and summer
I am using ASP.NET with C#
Posted
Comments
Sergey Alexandrovich Kryukov 3-Nov-13 18:26pm    
Why do you think it needs any code?
—SA

1 solution

It depends on the OS used to host your HTTP server, but most of OS are configured to automatically switch summer saving time shift on and off, depending on location and date. You don't have to worry about it. System.DateTime.Now will simply give you correct time.

Another solution is to use UTC time only on the server side (System.DateTime.UtcNow. The client-side code can translate UTC to their local times, according to the location and culture of the local systems.

Please see:
http://msdn.microsoft.com/en-us/library/System.DateTime%28v=vs.110%29.aspx[^],
http://msdn.microsoft.com/en-us/library/system.datetime.now(v=vs.110).aspx[^],
http://msdn.microsoft.com/en-us/library/system.datetime.utcnow%28v=vs.110%29.aspx[^].

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900