I have a function that gets a date from a jQuery calendar and then formats it in year-month-day.
The date I get for the calendar is 03/04/2013 for dateString and then I want it in the format of 2013-03-04. But the date I am getting for start_date is 2013-21-04. Strange because it had been ok, I think.
function makeUpDates() {
// concantenate values to date_start and date_end hidden inputs
var dateString = document.getElementById('date').value, date = new Date(dateString);
document.getElementById('date_start').value = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + ("0" + date.getDate()).slice(-2);
var numDays = document.getElementById('slider').value;
date.setDate(date.getDate() + parseInt(numDays));
var dateEnd = date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + ("0" + date.getDate()).slice(-2);
document.getElementById('date_end').value = dateEnd;
}