How to format date in asp.net mvc 5
问题 I am trying to format a date in asp.net MVC 5 by setting in a model class but not getting the desired result. Please view the date below: 10/10/2010 12:00:00 AM I want to change the above date in the following format:- OCT-10-2014 Please view my model class below [DisplayFormat(DataFormatString = "{0:MMM-dd-yyyy}", ApplyFormatInEditMode = true)] [Required(ErrorMessage = "Date is required")] public DateTime? DateOfBirth { get; set; } The above code is not formatting in the required format .