我居住在南非,使用en-ZA文化,我们的日期格式采用dd/mm/yyyy
格式输入。
我有一个视图接受一个模型:
public class UserInfoModel
{
public DateTime DateOfBirth{get;set;}
// some other properties here
}
当用户输入日期 ie:
04/15/1981
,我在我的post方法中得到的日期时间是1981年4月15日,然而,当插入以下日期15/04/1981
时,模型中的DateOfBirth属性返回null
。有没有一种方法可以全局更改日期的解析方式(在我的整个应用程序中)?
我在web.config中添加了以下内容:
<system.web>
<globalization culture="en-ZA" uiCulture="en-ZA"/>
</system.web>
但这似乎没有什么区别。