Kentico - Not able to save the DateTime in “DD/MM/YYYY” format

↘锁芯ラ 提交于 2021-02-11 17:44:44

问题


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:

Can anyone please suggest for the same?

Thanks


回答1:


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.



来源:https://stackoverflow.com/questions/61114448/kentico-not-able-to-save-the-datetime-in-dd-mm-yyyy-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!