validating date format not working

点点圈 提交于 2019-12-05 13:48:00
nomad

I found the solution here: ASP.NET MVC3 - DateTime format and it had to do with globalization.

My locale is en-CA and

System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern

gives "dd/MM/yyyy".

So in Web.config under <system.web> I included

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

So the DateTime format is working for me now.

P.S.

A safe way to pass dates without worrying about specific culture is to use ISO 8601 format - yyyy-MM-dd (or yyyy/MM/dd which also works).

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