내 커뮤니티 업적 표시줄을 확대합니다.

Submissions are now open for the 2026 Adobe Experience Maker Awards

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

HTML personalization - how to get first day of current month and x days after

Avatar

Level 5

Hello everyone,

 

I try to get in my HTML delivery something like this with the date and make a personalization, here is my example :

You can travel between the 01/04/2022 until the 15/05/2022 

 

So I want to get the first day of the current month until another day + 45 days for example.

Is something like this possible with personalization ? Can someone help me on this possible code ?

 

Thank you in advance for your help.

Kind regards.

EDIT : 

I successfully got the first day of current month with this :

var date = new Date();
var firstDay = new Date(date.getFullYear(), date.getMonth(), 1);

Result

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

 

Question remain is, how to get the other date + 45 days based on the firstDay ?

Thank you for your help.

 

 

 

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Community Advisor

Hello @thibaultb473199 ,

for example taken from https://stackoverflow.com/questions/563406/how-to-add-days-to-date 

 

Date.prototype.addDays = function(days) {
    var date = new Date(this.valueOf());
    date.setDate(date.getDate() + days);
    return date;
}

var date = new Date();

console.log(date.addDays(5));

Marcel

원본 게시물의 솔루션 보기

1 답변 개

Avatar

정확한 답변 작성자:
Community Advisor

Hello @thibaultb473199 ,

for example taken from https://stackoverflow.com/questions/563406/how-to-add-days-to-date 

 

Date.prototype.addDays = function(days) {
    var date = new Date(this.valueOf());
    date.setDate(date.getDate() + days);
    return date;
}

var date = new Date();

console.log(date.addDays(5));

Marcel