Adding days | Community
Skip to main content
Level 3
January 23, 2023
Solved

Adding days

  • January 23, 2023
  • 1 reply
  • 695 views

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") %>

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SatheeskannaK

Hi @justinbr17,

 

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!

1 reply

SatheeskannaK
Community Advisor
SatheeskannaKCommunity AdvisorAccepted solution
Community Advisor
January 23, 2023

Hi @justinbr17,

 

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!

Thanks, Sathees