MVC DataType.Date EditorFor won't display date value in Chrome

... but it does display it correctly on Internet Explorer.

I found solution on stackoverflow.com and the point is that the date needs to be formated as YYYY-MM-DD in order to be displayed correctly in Chrome.

A valid full-date as defined in [RFC 3339], with the additional qualification that the year component is four or more digits representing a number greater than 0.

This can be done by setting attribute to your model property:

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

No comments:

Post a Comment