Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Solved! Go to the solution
This is an accepted solution.
Hi @SergioCosta,
Please change code:
{% assign i_date = settings.sale_begin_date | date: '%m-%d-%Y' %}
=>
{% assign i_date = settings.sale_begin_date | date: 'format: 'default'' | date: '%s' %}
with the format of the date as 'Y-M-D', for example: '2022-12-16'
Hope it helps!
Hi @SergioCosta,
Please change code:
{% assign today_date_ts = today_date | date: '%s' | plus: 0 %}
=>
{% assign today_date_ts = 'now' | date: '%d' | plus: 0 %}
Hope it helps!
Thank you very much for pitching in but that gives me the day of the month for today, not the timestamp.
%s should give me the timestamp, yet it's returning the month. And this was working a week ago, which brings me to believe there was a bug induced in Shopify meanwhile.
Hi @SergioCosta,
You can try this:
{% assign today_date = 'now' | date: '%s' %}
{% assign today_date_ts = today_date | plus: 0 %}
Hope it helps!
Thank you.
That direct conversion works with 'now' but not with string dates, unfortunately. I do find it odd that converting to a date and then to timestamp doesn't work though. Any idea why that may be?
An example:
{% assign i_date = settings.sale_begin_date | date: '%m-%d-%Y' %}
{% assign i_date_ts = i_date | date: '%s' | plus: 0 %}
I'm using the first line above to make sure date formatation is recognized.
But this doesn't work either. It always returns the month.
{% assign i_date_ts = settings.sale_begin_date | date: '%s' | plus: 0 %}
Any ideas?
Thank you.
This is an accepted solution.
Hi @SergioCosta,
Please change code:
{% assign i_date = settings.sale_begin_date | date: '%m-%d-%Y' %}
=>
{% assign i_date = settings.sale_begin_date | date: 'format: 'default'' | date: '%s' %}
with the format of the date as 'Y-M-D', for example: '2022-12-16'
Hope it helps!
Thank you, that worked. I guess there is no way of keeping the date as mm-dd-yyyy?
Hi @SergioCosta,
It's the default format by Shopify, I'm not sure there is another way to change this.
Hope it helps!
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn 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, 2025