jQuery Datepicker datetime问题解析为@ Html.EditorFor MVC3
||
我已经阅读了很多有关设置正确的日期时间的问题,但是无法正确设置日期时间。
我的MVC3方法是数据库优先。模型是自动生成并手动更改的;
[DataType(DataType.Date)]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = \"{0:dd-MM-yy}\")]
public Nullable<System.DateTime> Datum { get; set; }
我认为这是一把直截了当的剃刀;
<div class=\"editor-field\">
@Html.EditorFor(model => model.Datum)
@Html.ValidationMessageFor(model => model.Datum)
</div>
在Shared_Layout中,我添加了这个
jQuery(function ($) {
$.datepicker.regional[\'nl\'] = {
closeText: \'Sluiten\',
prevText: \'←\',
nextText: \'→\',
currentText: \'Vandaag\',
monthNames: [\'januari\', \'februari\', \'maart\', \'april\', \'mei\', \'juni\',
\'juli\', \'augustus\', \'september\', \'oktober\', \'november\', \'december\'],
monthNamesShort: [\'jan\', \'feb\', \'maa\', \'apr\', \'mei\', \'jun\',
\'jul\', \'aug\', \'sep\', \'okt\', \'nov\', \'dec\'],
dayNames: [\'zondag\', \'maandag\', \'dinsdag\', \'woensdag\', \'donderdag\', \'vrijdag\', \'zaterdag\'],
dayNamesShort: [\'zon\', \'maa\', \'din\', \'woe\', \'don\', \'vri\', \'zat\'],
dayNamesMin: [\'zo\', \'ma\', \'di\', \'wo\', \'do\', \'vr\', \'za\'],
weekHeader: \'Wk\',
dateFormat: \'dd-mm-yy\',
firstDay: 1,
isRTL: false,
showMonthAfterYear: false,
yearSuffix: \'\'
};
$.datepicker.setDefaults($.datepicker.regional[\'nl\']);
$.datepicker.setDefaults({ dateFormat: \'dd-mm-yy\' });
});
在EditorFor字段中,日期显示为dd-mm-yyyy
datepicker的格式正确为dd-mm-yy
从日期选择器中解析日期后,日期格式突然变为mm / dd / yyyy
没有找到相关结果
已邀请:
1 个回复
期差骇蓟
问候,罗伊