1

I am working on MVC project, but there's a problem in using Date Format.

Here is my code:

[DisplayFormat(DataFormatString = "{0:dd-MM-yyyy}", ApplyFormatInEditMode = true)]
[DataType(DataType.Date)]
public Nullable<System.DateTime> docDate { get; set; }

and in the HTML side

 @Html.EditorFor(m => m.docDate)    

and I do not know where is the problem the format always came like this "MM/dd/yyyy"

please help me in this issue.

Pedro Coelho
  • 1,411
  • 3
  • 18
  • 31
Zozo
  • 19
  • 2
  • I try to use this but it came alse "MM/dd/yyyy" – Zozo Nov 01 '20 at 12:08
  • 1
    @Zozo - Look at the following post: [Specify Date format in MVC5 (dd/MM/yyyy)](https://stackoverflow.com/q/43820926/6630084). The `DisplayFormat` is intended for **displaying** and has no effect on the `datepicker` control. – Jackdaw Nov 01 '20 at 13:53
  • Does this answer your question? [Specify Date format in MVC5 (dd/MM/yyyy)](https://stackoverflow.com/questions/43820926/specify-date-format-in-mvc5-dd-mm-yyyy) – Ian Kemp Nov 02 '20 at 09:06
  • Maybe, using jquery is also an option. `$(function () { $("#docDate").datepicker(); $("#docDate").datepicker("option", "dateFormat", 'dd-mm-yy'); });` – Muzaffer Galata Nov 02 '20 at 10:09

0 Answers0