I have problem in regarding with converting the datetime to date using a model.
Model from Class Library
public partial class LoanCo
If when defining in model does not work, you can use inside your view file:
@String.Format("{0:dd/MM/yyyy}",ViewBag.TerminoDaAvaliacao)
This ViewBag contains a DateTime value. The time disapears with this format definition. It is not necessary to change DateTime by Date inside the Model file definition.
I think it is a bug for dateformat escape chars on dotnet core. None of above solutions worked for me. Only this method solved my problem. why does DateTime.ToString("dd/MM/yyyy") give me dd-MM-yyyy?
[DisplayFormat(DataFormatString = "{0:dd'/'MM'/'yyyy}", ApplyFormatInEditMode = true)]
or
<input asp-for="DateProperty" asp-format="{0:dd'/'MM'/'yyyy}">
This might be extremely helpful sometimes,
<input asp-for="DateProperty" asp-format="**@Model.DateProperty.ToString($"{0:dd/MM/yyyy}")**">