Daylight Time Zone conversion in C# asp.net -
how check whether particular time zone falls under "daylighttimezone" or not using c# asp.net?
if time zone falls under "daylighttimezone" should changing time standard time zone?
i time zone(time zones listed in windows os) input user , store in database,whenever user logs in display time , date based on timezone selected user.now role daylightsaving play here? whether changes should made if particular timezone falls under "daylightsavingzone".
use timezoneinfo
class introduced in .net 3.5.
it's not clear bigger goal is, timezoneinfo
should cover whatever you're trying do, such converting 1 time zone another. it's not simplest class use correctly, partly because datetime
type badly designed start with, unfortunately :(
i'm working (occasionally!) on new date , time library .net called noda time, unfortunately that's not ready yet :(
edit: okay, steps should be:
- work out how time zone user in appropriate form
timezoneinfo
. you'll want end storingid
in database. - when want display time:
- fetch time zone using
findsystemtimezonebyid
- get current time using
datetimeoffset.utcnow
- call
timezoneinfo.converttime
convert target time zone - format result appropriately user
- fetch time zone using
Comments
Post a Comment