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?
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" />
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.
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.
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"));
It's not the most elegant solution, but it's the only one that is working