Date format in ASP.Net (MVC)

Displaying a dates in the client culture format is as as easy as:

  • Use the DataType attribute to describe the type in your ViewModel – https://stackoverflow.com/questions/133671/format-date-on-binding-asp-net-mvc/4058891#4058891
public class Model 
{
  [DataType(DataType.Date)]
  public DateTime? Due { get; set; }
}
  • Add the Globalization element to your web.config file to respect the Culture and UICulture of the client: https://msdn.microsoft.com/en-us/library/ydkak5b9(v=vs.71).aspx
  <system.web>
    <globalization culture="auto:en-US" uiCulture="auto:en-US"/>
    <compilation targetFramework="4.6.1" debug="true" />
    <httpRuntime targetFramework="4.6.1" />
  </system.web>

 

  • Make certain that the browser is set to the correct language, which determines culture. In Chrome this means setting the default to the language and also prioritising that language by moving it to the top of the list.

At this point, your date will display in the culture as defined in the browser, with the fallback of en-US as specified in the Web.Config file.