I have a datepicker that I want to display in MM/DD/YYYY. However I'm using a mysql db which wants YYYY-MM-DD. As it stands right now its saving but the day and month are being reversed.
Right now I have an initalizer, date_time_formats.rb which has:
Date::DATE_FORMATS[:default] = '%m/%d/%Y'
Also in my datepicker jscript I have the correct format which I want to display:
$(this).datepicker({"format": "mm/dd/yyyy", "weekStart": 0, "autoclose": true, "startDate":new Date()});
I've tried things like this:
Date.strptime(params[:location], "%d/%m/%Y")
But I get a HashWithIndifferentAccess error.
How can I reformat the date in the params hash prior to assigning to an instance of the model? The reason being it seems to get rejected from the model if the date would be invalid (ex. April 4, 2013 is fine, but April 20, 2013 is not because there is no 20th month). I'm a big time rails novice so maybe I'm wrong but thats how it appears to be working. Thanks!