I'm having problems with the date format in en in an asp.net mvc application. Where it displays error if the date is in the dd / MM / yyyy HH: mm format, and only lets the date if it is not formed MM / dd / yyyy HH: mm .
Model
[Display(Name = "Data de Publicação", Description = "Selecione uma data futura para agendar uma publicação")]
[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd/MM/yyyy HH:mm}", ApplyFormatInEditMode = true)]
public System.DateTime DataPublicacao { get; set; }
View
<div class="form-group">
@Html.LabelFor(model => model.DataPublicacao, htmlAttributes: new { @class = "control-label col-xs-12 col-sm-12 col-md-12" })
<div class="col-xs-12 col-sm-12 col-md-12">
@Html.TextBoxFor(m => m.DataPublicacao, "{0:dd/MM/yyyy HH:mm}", htmlAttributes : new { @class = "form-control date-timepicker"})
@Html.ValidationMessageFor(model => model.DataPublicacao, "", new { @class = "text-danger" })
</div>
</div>
Javascript datetimepicker
$('.date-timepicker').datetimepicker({
locale: 'pt-br',
keepOpen: true,
showTodayButton: true,
format: 'DD/MM/YYYY HH:mm'
});
Webconfig :
<system.web>
<globalization culture="pt-BR" uiCulture="pt-BR" />
<compilation debug="true" targetFramework="4.5.2" />
<httpRuntime targetFramework="4.5.2" />
</system.web>
Result: