简体   繁体   中英

Daylight Time Zone conversion in C# asp.net

How to check whether a particular time zone falls under "DAYLIGHTTIMEZONE" or not using C# asp.net?

If the time zone falls under "DAYLIGHTTIMEZONE" should i be changing the time into standard time zone?

I will get the time zone(Time Zones Listed in Windows OS) as input from user and store it in database,whenever the user logs in i will display the time and date based on the timezone selected by the user.Now what role does daylightsaving play here? Whether any changes should be made if the particular timezone falls under "DaylightsavingZone".

Use the TimeZoneInfo class introduced in .NET 3.5.

It's not clear what your bigger goal is, but basically TimeZoneInfo should cover whatever you're trying to do, such as converting from one time zone to another. It's not always the simplest class to use correctly, partly because the DateTime type is badly designed to start with, unfortunately:(

I'm working (occasionally!) on a new date and time library for .NET called Noda Time , but unfortunately that's not ready yet:(

EDIT: Okay, so your steps should be:

  • Work out how to get the time zone from the user in an appropriate form for TimeZoneInfo . You'll want to end up storing the Id in the database.
  • When you want to display a time:

I think you are looking for TimeZone.IsDaylightSavingTime

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM