I have problem in regarding with converting the datetime to date using a model.
Model from Class Library
public partial class LoanContract
{
[DisplayFormat(DataFormatString = "{0:MM/dd/yyyy}")]
public DateTime LoanDateStart { get; set; }
}
Model from Project
public class ModelLoan
{
public LoanContract loanContract { get; set; }
}
Code in controller
myList.loanContract = new LoanContract { LoanDateStart = DateTime.Today };
View:
<input disabled type="date" asp-for="loanContract.LoanDateStart" id="dpDateNow" class="form-control" />
It show like this: yyyy-MM-dd
what I want to achieve is that I want to change it to MM/dd/yyyy
. I tried using .ToString("MM/dd/yyyy")
but it doesn't work.