Kentico - Not able to save the DateTime in "DD/MM/YYYY" format
Asked Answered
P

1

0

I am working on Kentico 12 MVC Site in version 12.0.59 and default culture set to "en-AU".

I have created a Form named "Sample Form".

When I am trying to save the datetime in either "MM/DD/YYYY" or "YYYY/MM/DD" it works correctly and saves the data in the database for the form.

But when I try to save the datetime in format "DD/MM/YYYY" and click on Submit button to save the data in database, it shows the error as follows:

enter image description here

Can anyone please suggest for the same?

Thanks

Pitch answered 9/4, 2020 at 5:18 Comment(0)
R
0

One potential reason for that is a missing culture setting for the current thread in the code. It is not enough just to select the default culture "en-AU" in the Kentico admin interface. In the code before processing your request you should set the desired culture for the thread as well:

Thread.CurrentThread.CurrentUICulture = yourDefaultOrSelectedCulture;
Thread.CurrentThread.CurrentCulture = yourDefaultOrSelectedCulture;

In Kentico example Dancing Goat MVC website you can see this implemented in MultiCultureMvcRouteHandler.cs code file.

Raulrausch answered 9/4, 2020 at 9:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.