This is the code I have right now.
var DateHelper = {
addDays : function(aDate, numberOfDays) {
aDate.setDate(aDate.getDate() + numberOfDays); // Add numberOfDays
return aDate; // Return the date
},
format : function format(date) {
return [
("0" + (date.getMonth()+1)).slice(-2), // Get month and pad it with zeroes
("0" + date.getDate()).slice(-2), // Get day and pad it with zeroes
date.getFullYear() // Get full year
].join('/'); // Glue the pieces together
}
}
// With this helper, you can now just use one line of readable code to :
// ---------------------------------------------------------------------
// 1. Get the current date
// 2. Add 10 days
// 3. Format it
// 4. Output it
// ---------------------------------------------------------------------
document.write( DateHelper.format(DateHelper.addDays(new Date(), 7)));
<!DOCTYPE html>
<html>
<body>
<h2>My First Web Page</h2>
<p>My first paragraph.</p>
<p>future date code.</p>
<script>
document.write("Offer Ends:");
</script>
</html>
How would I add this formatting into the original working code?