Nissim Nissim - 7 months ago 25
Vb.net Question

Detect if the DST is currently enabled

I need to find an easy way to know if the local machine's 'automatically adjust clock for Daylight Saving Time' option is enabled.
If the option's on, I need to know whether it is currently applied (i.e. is it DST currently in the system).
Thanks in advance

Answer

You can find the current system default time zone and whether it's currently using DST like this (.NET 3.5 onwards):

TimeZoneInfo zone = TimeZoneInfo.Local;
if (zone.SupportsDaylightSavingTime)
{
    Console.WriteLine("System default zone uses DST...");
    Console.WriteLine("In DST? {0}", zone.IsDaylightSavingTime(DateTime.UtcNow);
}
else
{
    Console.WriteLine("System default zone does not use DST.");
}