ASP.NET Core DateTime - ToLocalTime vs ConvertTime
1 answer
Both methods should work fine, I don't think one is more correct than the other.
The most obvious difference in their standard usage is that it System.DateTime.ToLocalTime()
uses the local timezone provided by the system, while it TimeZoneInfo.ConvertTime()
uses whatever timezone you give it (e.g. hardcoded CET).
In both cases, you should pay attention to the property Kind
that can sometimes ruin your day.
Anyway, you can check this question and of course the MSDN documentation of both methods, which summarizes their behavior quite well.
+2
source to share