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)
By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024