get the date 5 weeks from now in javascript

You can use the built-in Date object in JavaScript and its setDate method to get the date 5 weeks from now. Here's an example code snippet:

index.tsx
const today = new Date();
const inFiveWeeks = new Date(today.setDate(today.getDate() + (5 * 7)));
console.log(inFiveWeeks);
124 chars
4 lines

In the code above, we first create a Date object for today's date. Then, we use the setDate method to set the date to 5 weeks from now. We do this by adding 5 times 7 (days in a week) to today's date using the getDate method. Finally, we log the resulting Date object to the console.

related categories

gistlibby LogSnag