Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Join us for our next Adobe Campaign Community Q&A Coffee Break, on Thursday, February 9th @ 9.30 am IST & 9 am PT
SOLVED

Adding days

Avatar

Level 4

Hi All,

 

I am using the 'formatDate' to get the current date, but I would also like to add 60 days to the current date. 

<%= formatDate(new Date(), "%2M/%2D/%4Y") %>

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @StrawHatM23,

 

You can have a content block with this code and see if that helps,

 

<%
var date = new Date();
// Add x days to specified date
date.setDate(date.getDate() + 60);
var newdate = ("0"+(date.getMonth()+1)).slice(-2) + "/" + ("0" + date.getDate()).slice(-2) + "/" + date.getFullYear();
document.write(newdate);
%>

 

Output: 03/24/2023

 

Thanks!

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Hi @StrawHatM23,

 

You can have a content block with this code and see if that helps,

 

<%
var date = new Date();
// Add x days to specified date
date.setDate(date.getDate() + 60);
var newdate = ("0"+(date.getMonth()+1)).slice(-2) + "/" + ("0" + date.getDate()).slice(-2) + "/" + date.getFullYear();
document.write(newdate);
%>

 

Output: 03/24/2023

 

Thanks!