aspnetcore icon indicating copy to clipboard operation
aspnetcore copied to clipboard

DateTime.Now on Safari/Mac

Open WardDurossette opened this issue 8 years ago • 4 comments

System.DateTime.Now returns a different time in Blazor than "regular dotNET".

------- ASPNET CORE

PS /Users/warddurossette/Projects/FirstCoreWebApp> dotnet --version 2.1.4

CODE: await context.Response.WriteAsync($"Hello Ward! The current time is: {System.DateTime.Now}"); OUTPUT: Hello Ward! The current time is: 02/12/2018 20:14:43

------- BLAZOR

CODE:

Hello, world!

The current time is: @System.DateTime.Now

OUTPUT: Hello, world! The current time is: 02/13/2018 02:14:43

WardDurossette avatar Feb 13 '18 02:02 WardDurossette

Interesting... Looks like 1 is UTC and the other is UTC +- 6 ...

muqeet-khan avatar Feb 13 '18 05:02 muqeet-khan

@muqeet-khan yes, thanks, I should have mentioned that. I am CST here in Texas, that's exactly what it is. The Blazor flavor is displaying UTC, default dotNET behavior shows local time zone. Currently Central Standard Time (CST) is -6 from UTC.

I did see another issue asking for localization, and suspect this is a symptom of not being localized.

WardDurossette avatar Feb 13 '18 05:02 WardDurossette

Thanks for reporting this. I think we should consider it a duplicate of aspnet/AspNetCore#5471.

SteveSandersonMS avatar Feb 13 '18 16:02 SteveSandersonMS

One thing to note about localization - I watched @csharpfritz do a live demo of Blazor and on the Windows platform DateTime.Now displayed the correct time. The UTC display only occurs on the Mac; I am thinking because of the funny way *unix does system clock time compared windows.

WardDurossette avatar Feb 13 '18 17:02 WardDurossette