Hello,
I want to create a recurring delivery with content that varies depending on the date.
I would like to be able to display the "July" block only in July and the "August" block only in August.
Do you know what conditions I have to put in my HTML to have a structure like this:
- Generic content
- If the date is after 01/07/25 and strictly before 01/08/25 then "July Block"
- If the date is after 08/01/25 and strictly before 09/01/25 then “August Block”
- Generic content
I don't know how to setup the conditions in red below :
<% if ( curentdate > "01/07/2025 00:00:00" && curentdate < "01/08/2025 00:00:00" ) { %>July Block<% } %>
Thank you in advance for your help.
Arthur
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
@Arthur_Le_Bris_U-Tech , You can try the below,
<body>
<%
var currentDate = new Date();
var Date1 = new Date('2025-07-15');
var Date2 = new Date('2025-08-22');
var Date3 = new Date('2025-08-23');
var Date4 = new Date('2025-08-30');
%>
<% if (currentDate >= Date1 && currentDate <= Date2) { %>
<p>Content for Block 1 : from 15/07/25 to 22/08/25</p>
<% } %>
<% if (currentDate >= Date3 && currentDate <= Date4) { %>
<p>Content for Block 2 : from 23/08/25 to 30/08/25</p>
<% } %>
<% } else { %>
<p>Default content block if any</p>
<% } %>
</body>
You can use formatDate and get the 'month' value for personalization,
<% if ( formatDate(new Date(), "%2M") == '01' ) { %>
Insert content here for January Month
<% } %>
Hi @ParthaSarathy,
Thank you for this answer which responds exactly to the use case described.
However, I realize that my request was poorly worded because my case is a little more complex.
I would like to be able to display the block between 2 given dates (not necessarily a full month).
For example:
- Block 1 : from 15/07/25 to 22/08/25
- Block 2 : from 23/08/25 to 30/08/25
Thanks
Views
Replies
Total Likes
@Arthur_Le_Bris_U-Tech , You can try the below,
<body>
<%
var currentDate = new Date();
var Date1 = new Date('2025-07-15');
var Date2 = new Date('2025-08-22');
var Date3 = new Date('2025-08-23');
var Date4 = new Date('2025-08-30');
%>
<% if (currentDate >= Date1 && currentDate <= Date2) { %>
<p>Content for Block 1 : from 15/07/25 to 22/08/25</p>
<% } %>
<% if (currentDate >= Date3 && currentDate <= Date4) { %>
<p>Content for Block 2 : from 23/08/25 to 30/08/25</p>
<% } %>
<% } else { %>
<p>Default content block if any</p>
<% } %>
</body>
This is exactly what I needed ! Thank you @ParthaSarathy !