how do I subtract one week from this date in jquery?

You can modify a date using setDate. It automatically corrects for shifting to new months/years etc.

var oneWeekAgo = new Date();
oneWeekAgo.setDate(oneWeekAgo.getDate() - 7);

And then go ahead to render the date to a string in any matter you prefer.

Leave a Comment