I'm running into an issue on a clients production server where the month & day is being swapped on a view model property when saving an entity. For example if I were to select April 9th 2012 (04/09/2012)
within the datepicker the date is being saved as September 4th 2012 (09/04/2012)
.
The same controller actions are working correctly on local development / test server and I'm unsure of what to look at next?
The property in the viewmodel:
[DisplayName("Date")]
[Required]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:MM/dd/yy}")]
[DataType(DataType.Date)]
public DateTime StartDate { get; set; }
The helper within the relevant view:
@Html.EditorFor(model => model.StartDate)
The jquery ui datepicker:
$('#StartDate').datepicker({ dateFormat: 'mm/dd/yy' });
The stripped down version of the controller:
public ActionResult Create(BulletinBoardViewModel bulletin)
{
var model = AutoMapper.Mapper.Map<BulletinBoardViewModel, BulletinBoard>(bulletin);
_repository.Save(model);
return RedirectToAction("Index");
}
The headers of the related post:
StartDate:04/09/2012
Cache-Control:private, s-maxage=0
Content-Length:131
Content-Type:text/html; charset=utf-8
Date:Tue, 10 Apr 2012 02:43:16 GMT
Location:/BulletinBoard
Server:Microsoft-IIS/7.5
X-AspNet-Version:4.0.30319
X-AspNetMvc-Version:3.0
X-Powered-By:ASP.NET