I can't get this to work. I have a short date like this '6/8/2011'
The code on the button includes this
and the function
var shortDate = document.getElementById('theShortDate').innerHTML; // displays the short date
var theDate = new Date();
theDate.setDate(theDate.getDate() + days); // adds days to the date (in my case - 7 days)
// Now the date will display as a full date ie: Sat Aug 13 2011 15:41:44 GMT+1200 (NZST)
// I need to convert it here back to 13/8/2011
// I have tried theDate.toString('d/M/yyyy'); but no luck
var currentDay = theDate.getDay();
var currentMonth = theDate.getMonth() + 1;
var currentYear = theDate.getFullYear();
var shortDate = currentDay + '/' + currentMonth + '/' + currentYear; // I tied this as well but it formats the current date
document.getElementById('theShortDate').innerHTML = shortDate; // display the new date
The div that holds the short date format is only there for display. I don't really need it as the function will ALWAYS add or subtract 7 days. It is a calendar display. Why is my function not formatting the new date instead of the current date.