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
You can find the current system default time zone and whether it is currently using DST (Daylight Saving Time) 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.");
}
Another option may be is DateTime.IsDaylightSavingTime
method. Check MSDN.
if (DateTime.Now.IsDaylightSavingTime())
Console.WriteLine("Daylight Saving");
else
Console.WriteLine("No Daylight Saving");
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