DatePicker format issue

北战南征 提交于 2019-12-08 00:06:51

问题


I'm trying to use Kendo UI DatePicker

 @(Html.Kendo().DatePickerFor(model => model.CalledInAt).Format("dd/MM/yyyy HH:mm tt").Value(DateTime.Now).HtmlAttributes(new { @style = "width:205px" }))

I'm using ASP.NET MVC 4 with entity framework.

when i try to submit a form it gives me the error. "The value '19/09/2013 04:08 AM' is not valid for CalledInAt"

If i change the format to dd/MM/yyyy then it works. something like below works.

@(Html.Kendo().DatePickerFor(model => model.CalledInAt).Format("MM/dd/yyyy HH:mm tt").Value(DateTime.Now).HtmlAttributes(new { @style = "width:205px" }))

what would be the reason?


回答1:


Try to set the culture in web config that match with date format.

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

See this link ASP.NET Date time support for different cultures



来源:https://stackoverflow.com/questions/18893352/datepicker-format-issue

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