Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DateTime returns wrong time after updating target framework to net5.0 #41429

Closed
pureggerstefan opened this issue Aug 27, 2020 · 5 comments
Closed
Labels
area-System.DateTime question Answer questions and provide assistance, not an issue with source code or documentation.
Milestone

Comments

@pureggerstefan
Copy link

After updating a Blazor WebAssembly App to .net5.0 a problem with DateTime occurs. When using e.g. DateTime.Now, it does not access the local time on my machine, instead it returns the current UTC-Time instead of the expected CEST. Changing any of my settings on the local machine does not affect the given value. With the previous used framework (.netstandard2.1), this problem does not occur.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the untriaged New issue has not been triaged by the area owner label Aug 27, 2020
@Dotnet-GitSync-Bot
Copy link
Collaborator

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@joperezr
Copy link
Member

cc: @marek-safar

Thanks for logging the issue @pureggerstefan can you please verify which version of the sdk did you use when you updated to .NET 5? I ask because we recently (I think it was after preview 7 sdk) changed how TimeZone info is packed in a wasm app but the default is that we will pack the timezone info with your application and you should get the right behavior when doing DateTime.Now unless you manually set the property: #37973 (comment) which will force UTC to always be used. The purpose of this property is to make your wasm app smaller since it won't need to pack the TimeZone info on your app, but as I said the default is to pack it unless you set the property.

@joperezr joperezr added question Answer questions and provide assistance, not an issue with source code or documentation. and removed untriaged New issue has not been triaged by the area owner labels Aug 27, 2020
@joperezr joperezr added this to the 5.0.0 milestone Aug 27, 2020
@joperezr
Copy link
Member

FWIW I just tried preview 8 and it seems like DateTime.Now is correctly displaying localized TimeZone for me. @pureggerstefan I would suggest updating to preview 8 and trying again, it should work.

@marek-safar
Copy link
Contributor

/cc @EgorBo

@pureggerstefan
Copy link
Author

@joperezr Thank you! Updating from preview 7 to 8 solved the issue. Now every information displayed is correct.

@ghost ghost locked as resolved and limited conversation to collaborators Dec 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.DateTime question Answer questions and provide assistance, not an issue with source code or documentation.
Projects
None yet
Development

No branches or pull requests

6 participants