Example 1 — Match TimeZoneInfo.Local
Show that the DateTime method and the zone method agree, whatever your time zone is.
using System;
class Program {
static void Main() {
DateTime dt = new DateTime(2026, 7, 1, 12, 0, 0);
bool a = dt.IsDaylightSavingTime();
bool b = TimeZoneInfo.Local.IsDaylightSavingTime(dt);
Console.WriteLine(a == b);
}
} How It Works
- Midsummer date. July 1 is a common DST date in the northern hemisphere.
- Two ways to ask. One call uses the DateTime method, the other uses the local
TimeZoneInfo. - They agree. The instance method simply asks the local zone, so the comparison is
True. - Do not print a or b. Their value would change from computer to computer; the comparison never does.

