Adding Days to a Date

I have FINALLY figured out how to add todays date in my website by using code: here is the code I used and it worked great:
const today = new Date();
// The next three lines format the way the date will appear
const options = {
day: “numeric”,
month: “long”,
year: “numeric”
// Sets the property of the text element to be a string representing today’s date in US English
$w(“#text48”).text = today.toLocaleDateString(“en-US”, options);

However, now I am needing to add 114 days to that date?
We are wanting the date to reflect 114 days in advance for breeding purposes, is there a way that I can do that?

Thanks in advance, I owe you one!

Here’s a quickie sample you can play around with:

$w.onReady(function () {
   let today = new Date();
   console.log('today', today);
   let todayplus114 = addDays(today, 114);
   console.log('+114', todayplus114);

function addDays(date, days) {
   let result = new Date(date);
   result.setDate(result.getDate() + days);
   return result;

The addDays() function lets you use whatever number of days you want.

1 Like