Replies: 2 comments
-
Format codes are not C#, but the runtime: @dotnet/runtime |
Beta Was this translation helpful? Give feedback.
-
It formats in the "general" style of current culture. https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings#table-of-format-specifiers When a European culture is supplied or set as the default culture, it will format as European style.
The culture-aware formatting strings shouldn't be treated as a "shortcut". It's just follows current culture. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I wondered why C# does not yet provide a special shortcut for a popular European date style format
G or g format modifiers format date time in US-style (I know it depends on culture settings but in most cases we use G shortcut):
dateTime.ToString("G") is equivalent of dateTime.ToString("MM/dd/yyyy HH:mm:ss")
dateTime.ToString("g") is equivalent of dateTime.ToString("MM/dd/yyyy HH:mm")
why not to add an 'E' shortcut for European date style e.g.
dateTime.ToString("E") to be equivalent of dateTime.ToString("dd/MM/yyyy HH:mm:ss")
dateTime.ToString("e") to be equivalent of dateTime.ToString("dd/MM/yyyy HH:mm")
Beta Was this translation helpful? Give feedback.
All reactions