Recently upgrade one application from .NET Core 3.1 to .NET 5. For some reason the DateTimeKind was Local in 3.1 and now it is UTC in .NET 5.
I created a simple project showing this problem,
https://github.com/ShehulCS/Dotnet5DateTimeIssue
Question,
The issue you're describing is related to a bug fix.
In short, the Z
at the end of an ISO 8601 timestamp explicitly means UTC. The bug was that when such a value is obtained through model binding, it was previously being interpreted as DateTimeKind.Local
instead of DateTimeKind.Utc
. That bug has been corrected in 5.0.
The bug is described in this issue: https://github.com/dotnet/aspnetcore/issues/11584
It was fixed in this PR: https://github.com/dotnet/aspnetcore/pull/24893
A request to backport the fix to 3.1 was made (but denied) here: https://github.com/dotnet/aspnetcore/issues/27618
The new behavior is correct. If you were relying on the old behavior, you probably have other .NET code that needs to be corrected.
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