In this controller is a methd called PostHoliday(HolidayModel item) and the model has a start date and end date properties both of type DateTime
When I call it from jquery the date is always converted to US format. Therefore if after 12th of the month then the date is invalid and comes in as 01/01/0001
In another project outside of Umbraco I used IModelBinder and registered this in the global.asax.
IModelBinder dateBinder = new DateTimeModelBinder(); ModelBinders.Binders.Add(typeof(DateTime), dateBinder); ModelBinders.Binders.Add(typeof(DateTime?), dateBinder);
Tried registering the same thing in ApplicationEventHandler but this doesn't work
How can I get Umbraco API Controller to use UK date formats when model binding?
I've had the same problem. I posted the culture as a parameter to the WebAPI and then do this:
//Set the culture which is passed from the ajax call.
System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo(culture);
System.Threading.Thread.CurrentThread.CurrentCulture = ci;
System.Threading.Thread.CurrentThread.CurrentUICulture = ci;
Umbraco API Controller and UK Date format
Hi,
I have created an api controller using the following guide
http://our.umbraco.org/documentation/Reference/WebApi/
In this controller is a methd called PostHoliday(HolidayModel item)
and the model has a start date and end date properties both of type DateTime
When I call it from jquery the date is always converted to US format. Therefore if after 12th of the month then the date is invalid and comes in as 01/01/0001
In another project outside of Umbraco I used IModelBinder and registered this in the global.asax.
Tried registering the same thing in ApplicationEventHandler but this doesn't work
How can I get Umbraco API Controller to use UK date formats when model binding?
Thanks
Hello,
I've had the same problem. I posted the culture as a parameter to the WebAPI and then do this:
Jeroen
is working on a reply...