0

Similiar question like this one. I have a datepicker field in an ASP.NET Core razor page which I would like to format in Germany-style: dd.MM.yyyy (14.05.2019). However, all my formatting seems to get ignored.

I have already this on my model:

[DataType(DataType.Date)]
[DisplayFormat(DataFormatString = "{0:dd.MM.yyyy}", ApplyFormatInEditMode = true)]
public DateTime? DateFilter { get; set; }

And this in my view:

<input asp-for="DateFilter" class="form-control" asp-format="{0:dd.MM.yyyy}" />

Nevertheless in Chrome the picker gets displayed as MM/dd/yyyy. In Edge it shows as dd/MM/yyyy

Chrome:

enter image description here

Edge:

enter image description here

I even tried to set the default culture in my Startup.cs with no effect

options.DefaultRequestCulture = new RequestCulture(culture: "de-DE", uiCulture: "de-DE");

Any ideas what I'm still missing? Thanks!

Panagiotis Kanavos
  • 120,703
  • 13
  • 188
  • 236
silent
  • 14,494
  • 4
  • 46
  • 86
  • 1
    https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date#Value the format displayed in the browser is completely up to the browser and what the browser's locale is. The value submitted to the server will be in yyyy-mm-dd format though, regardless of the user's locale. `format` doesn't appear to be a valid `` attribute. – Jason Larke May 14 '19 at 11:30
  • thanks guys! Yes, seems to be a duplicate. I didn't think of looking for the HTML part of the issue. Thought it was related to my ASP-side of things. Can close this one. – silent May 14 '19 at 11:35

0 Answers0