I have issue with formatting date to dd MMM yyyy. when i try to format this date with Swedish culture I get date as 21 apr. 2023 where it should be 21 apr 2023 I tried below code in console app with .net core 7 and its same:
var date = DateTime.UtcNow;
var cultureInfo = CultureInfo.GetCultures(CultureTypes.AllCultures).FirstOrDefault(c => c.LCID == 29);
Console.WriteLine(cultureInfo.LCID);
var dateString = date.ToString("dd MMM yyyy", cultureInfo);
Console.WriteLine(dateString);
Please note this works when i run this program in Azure app service. so there must be something with my windows 11 enterprise 21H2 operating system or I am not sure where is the issue? Any help would be appreciated
I tried
var date = DateTime.UtcNow;
var cultureInfo = CultureInfo.GetCultures(CultureTypes.AllCultures).FirstOrDefault(c => c.LCID == 29);
Console.WriteLine(cultureInfo.LCID);
var dateString = date.ToString("dd MMM yyyy", cultureInfo);
Console.WriteLine(dateString);
I expect it to return 21 apr 2023