Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi to all
for my customer requirement I need to get the last day of the month starting from a given date
For example : I have
date = '2027-11-01'
I need to get endOfMonth='2027-11-30'
Any idea on how to get that result using liquid ?
Thanks
Hi,
Converting the given date to a Liquid date object and then using the date filter to get the last day of the month.
{% assign date = '2027-11-01' | date: "%Y-%m-%d" %}
{% assign endOfMonth = date | date: "%Y-%m-%d" | date_add: '1m' | date: "%Y-%m-01" | date_subtract: '1d' %}
End of Month: {{ endOfMonth }}
Hello
Thanks but I got an error => Liquid error: undefined filter date_add
In some use case my date can be for example '2027-11-16' and I need to get from that date '2027-11-30'
Need to check from our end. If you want you can contact us (details given at signature)
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025