Lava Filters - IsDateBetween
Category:Date
Description:Determine if the provided date falls within a given range.
Input: "Items": [
{
"Id": 1,
"Title": "Easter Devotional",
"FeaturedDates": "4/10/2022 to 4/20/2022"
},
{
"Id": 2,
"Title": "Christmas Devotional",
"FeaturedDates": "12/20/2022 to 12/31/2022"
},
]
Lava: {% assign today = '2022-04-17 07:00' | Date:'yyyy-MM-dd HH:mm' %}
{% for i in Items %}
{% assign startDate = i.FeaturedDates | Split:' to ' | First %}
{% assign endDate = i.FeaturedDates | Split:' to ' | Last %}
{% if i.FeaturedDates != '' %}
{% assign isFeatured = today | IsDateBetween:startDate,endDate %}
{% if isFeatured %}
{{i.Title}}
{% endif %}
{% endif %}
{% endfor %}
Output: Easter Devotional