Shopify to show product created and published date!

product published date in shopify

Sometime we want to show the product publish date on product template.

Here is the code to show product created and publish date on product page.

1) product.published_at :-  Returns the date and time the product was published.

2) product.created_at :-  Returns the date and time the product was created

For example:- I want to show the NEW badge on product pages which one are published less than 15 days ago.

 {% assign product_pub_at = product.published_at | date: '%s' %}
    
{% assign time_ago = 'now' | date: '%s' | minus: product_pub_at | divided_by: 86400 %}
                     
{% if time_ago < 15 %}
    <div class="new_banner prd">NEW</div>
{% endif %}  

For products added in the last 15 days or you can modify the days in coding.

shopify product created and published date

I hope this helps you ..

Thanks 🙂

If this help you then.. Can you buy a Cup of Coffee for me by nst webcreation paypal--OR-- nst webcreation blog coffee cup

Published by

Narender Singh

Myself Narender Singh Thakur ( NST ) and i share my Experience/Knowledge and Tricks for folks and beginners to solve their issues while making websites through this Planet.

Related Articles

2 thoughts on “Shopify to show product created and published date!”

Leave a Reply

Your email address will not be published. Required fields are marked *

Click to Chat