Ideally what i would like to do is take an input field attach a datepicker to it have someone pick a future date in time for example. [today is 08/09/2013 at the time of writing this and get 07/31/2013 in return.]
I want for no matter what date is picked, the input field using javascript, will always default the value to the Wednesday prior to the week in-which was the initial selected date value.
function getWednesday(date) {
var d = (date.getDay() == 0 ? 6 : date.getDay() - 3);
date.setTime(date.getTime() - (d * 24 * 60 * 60 * 1000));
return date;
}
This will only return the Wednesday of the current week. My understanding of the javascript functions getDay will only return 0-6 representing sun-sat. setTime function takes a string of milliseconds since January 1, 1970 and convert to a actual date in time and getTime does the exact opposite. I'm not sure im taking the right approch to have a solid solution to the problem. Thanks in Advance for any help