I am using C#. I need to get the local time zone info for the person running a web application.
I was wondering if:
TimeZoneInfo tzinfo = TimeZoneInfo.Local; TimeZoneInfo.ConvertTimeFromUtc(result.DueDate.Value, tzinfo);
is appropriate. Again depending on what time zone the person running the application is, I would like that to be reflected.
To get the current browser's time zone, you can use the getTimezoneOffset() method from the JavaScript Date object. The getTimezoneOffset() returns the time difference, in minutes, between UTC time and local time.
TimeZoneInfo Class represents any time zone in the world. Instance of TimeZoneInfo class is immutable, i.e., when we instantiate it the value can't be modified. We can't create an object of TimeZoneInfo class with a new keyword. If you have ever noticed, this is sealed class and also restricts the inheritance feature.
yes you are right, this is what you should use. Alternative can be
TimeZone localZone = TimeZone.CurrentTimeZone;
but the CurrentTimeZone
property corresponds to the TimeZoneInfo.Local
property so no difference really.
it displays the names for standard time and daylight saving time for the local time zone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With