Search code examples
c#datedatetimelocalizationdatetimeoffset

DateTime.ToUniversalTime applying -1 hour for October but not for November


If you run: (new DateTime(2021, 11, 01)).ToUniversalTime()
The result is: [01/11/2021 00:00:00]
But if you run: (new DateTime(2021, 10, 01)).ToUniversalTime()
There result is: [30/09/2021 23:00:00]

What gives?


Solution

  • You haven't specified what time zone you're in, but it's likely that it's somewhere which has Daylight Savings Time over the summer period, which ends somewhere between 2021/10/01 and 2021/11/01.

    For example, in Bulgaria (which your profile says you're from), daylight savings ends on 2021/10/31.