get the date 5 days ago in javascript

To get the date of 5 days ago in javascript, you can create a new Date object and subtract 5 from the date value using the setDate() method. Here's an example:

index.tsx
let today = new Date();
let fiveDaysAgo = new Date();
fiveDaysAgo.setDate(today.getDate() - 5);

console.log(fiveDaysAgo);
123 chars
6 lines

This will output the date 5 days ago from today's date.

gistlibby LogSnag