Format date within View in ASP.NET Core MVC

前端 未结 9 2135
借酒劲吻你
借酒劲吻你 2020-12-30 09:51

I have problem in regarding with converting the datetime to date using a model.

Model from Class Library

public partial class LoanCo         


        
9条回答
  •  [愿得一人]
    2020-12-30 10:32

    Try it with this in your model:

    [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:MM/dd/yyyy}")]
    

    And In your controller change DateTime to Date :

    myList.loanContract = new LoanContract { LoanDateStart = Date.Today };
    

    Hope this help you.

提交回复
热议问题