0

I'm currently trying to display a datetime in the format of the local culture of the user.

As an example, an user from the US will see a date as 20 June 2020 05.50 PM where as an user from germany will see the date as 20 Juni 2020, 17:50.

My issue is, that e.g for the german case, I'd like to have a Uhr added at the end, so it will be 20 Juni 2020, 17:50 Uhr as explained in this related question.

Is there any way to achieve that in .NET as well? In theory I could just keep checking the culture and add Uhr if it's a german one, but I assume that there are other cultures as well with a similar suffix.

Shawn
  • 177
  • 7
  • Did you try adding `tt` to your format string? That should include the am/pm designator which it sounds like may the uhr as well – pinkfloydx33 Jun 17 '20 at 08:55
  • @pinkfloydx33 Did you mean ```t``` (or ```T```)? That adds the am/pm as you said but sadly only displays the time for the german culture. – Shawn Jun 17 '20 at 09:00
  • Yah I just tried it and it didn't work. You could override the Am/pm designator for the culture to include the Uhr and then use the standard format strings... but you'd have to set it per culture it looks like – pinkfloydx33 Jun 17 '20 at 09:04
  • https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings#ttSpecifier –  Jun 17 '20 at 09:15

0 Answers0