DateTime wrong Culture


Hello Dear Experts,

Could you please help me to resolve the following issue.

The site initially had globalization culture set to en-US. DateTime are defined in wrong format for us. I've replaced the culture with

<globalization culture="en-AU" uiCulture="en-AU"

In the controller that intitializes the form with DateTime property checking current culture

string currentCulture = EPiServer.Globalization.GlobalizationSettings.CultureLanguageCode;

it's set to correct one en-AU, but when checking the DateTime format it's still in en-US

Why this happens?



Jul 22, 2020 1:54

Are you running it in Azure? Then it might have something to do with where... As dates are stored in UTC you might want to force the timezone for the website in the appsettings, something like this: <add key="WEBSITE_TIME_ZONE" value="W. Europe Standard Time" />

Jul 23, 2020 7:18

Hi Olga

If the issue is that the dates are shown using US format instead of Australian format, then I posted a tiny fix in this thread last year.

However, the issue was later fixed in CMS 11.19.1, as shown in this bug report.

Jul 23, 2020 16:42

The problem is not how it shows in edit format. When I'm testing locally, I output DateTime to the page and submit the form back. The dates are in US culture. 

Jul 26, 2020 21:45
Stefan Holm Olsen - Jul 27, 2020 6:05
Did you try my suggestion? Cause it applies both to public pages and to edit mode.
Olga - Jul 28, 2020 8:02
Thank you for your reply Stefan.
We are using Episerver.CMS.UI version 11.24.1, so the fix should be there. However it's not working correctly. I've tried your approach as well, but still no luck.

Weird, but none of the googled solutions are working for me, so as a temporary solution I've added date binder and force it there:

public class DateTimeModelBinder : IModelBinder
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
            var value = bindingContext.ValueProvider.GetValue(bindingContext.ModelName);
            var date = value.ConvertTo(typeof(DateTime), CultureInfo.GetCultureInfo("en-AU"));

            return date;

It's not the most elegant solution, but it's the only one that is working

Jul 28, 2020 22:39
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.