I have an ASP.NET Core MVC application with a view model which has a DateTime property for "Date of Birth":
[Required]
public DateTime DateOfBirth { get; set; }
I want to let the user to pick/enter date in dd/mm/yyyy format.
In the view originally I was using html Date type and it was working fine in Chrome but some issues in Edge and not working in IE 11 at all. Therefore I have decided to replace it with the jQuery DatePicker:
<input class="form-control datepicker" name="DateOfBirth" type="text" required>
In Js file:
$(".datepicker").datepicker({ dateFormat: 'dd/mm/yy' });
It all works fine as long as I pass value as mm/dd/yyyy format (12/12/2017). As soon as I change it to 13/12/2017 (dd/mm/yyyy) I get server side error saying that method arguments are not valid.
dd/MM/yyyyformat (or you need to create a custom ModelBinder to convert the dates to your formatweb.configfile, in the<system.web>section, add<globalization culture="en-AU" uiCulture="en-AU" />(or what ever culture you want)