Unable to set datetime format in MVC 4 using data annotations

前端 未结 3 1691
暖寄归人
暖寄归人 2020-12-14 09:41

I will try everything but not working this(dd/MM/yyyy) date format, this always gate mm/dd/yyyy

[Display(Name = \"Release D         


        
3条回答
  •  醉酒成梦
    2020-12-14 10:29

    {0:dd/mm/yyyy} should be {0:dd/MM/yyyy} because mm means minutes, not months:

    [Display(Name = "Release Date")]
    [DataType(DataType.DateTime)]
    [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:dd/MM/yyyy}")]
    public Nullable release_date { get; set; }
    

提交回复
热议问题