2
I’m having problems with the date format on en in an Asp.net mvc application. Where it displays error if the date is in the form dd/MM/yyyy HH:mm, and only let it pass if the date is in the 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 of startup of 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>
Upshot:
@Renan unfortunately the question which marked as duplicate, none of the answer was possible to solve my problem.
– Erico Souza
Erico, it would be good to then edit your question to indicate this. Link to the other question and say that no answer in it solved your case.
– Oralista de Sistemas