Get Current Date in Shopify: Display Today's Date in Shopify

Do you want to show today’s date in Shopify?

Many Shopify eCommerce, service provider websites, online journals, and frequently updated blogs may want to display the current date and time. This gives website visitors an idea about the current date and how long ago the content was published.

In this post, We will show you how to easily display today’s date or current time on your Shopify Store.

Showing Current Date in Shopify

Let’s take a look at how to easily display today’s date with day, month, and year on your Shopify website.

You can add this simple code in your Shopify store theme’s files where you want to display the current time.

{{ "now" | date: "%Y-%m-%d %H:%M" }}

Output

2022-04-14 16:10

 

Using the date filter in Liquid and Shopify

In Shopify’s Liquid language, the date filter converts a timestamp to another date format. For example, a blog article will have a published_at attribute, a Liquid object on which we can apply the date filter. I’ve specified the output inside the comment below:

{{ article.published_at | date: "%a, %b %d, %Y" }}
<-- Tues, Apr 30, 2019 -->

The date filter accepts the same parameters for formatting as Ruby’s strftime method. For creating custom formatting, try using a site like strfti.me to create the parameters that fit the output that you want.

It’s important to note that the output of date isn’t translated into other languages. To ensure dates are universal, consider using a numbered format like 2019-09-14.

The date filter also accepts some default format options:

{{ article.published_at | date: format: 'default' }}
<-- Tue, Apr 30, 2019, 6:55 am -0400 -->

{{ article.published_at | date: format: 'short' }}
<-- 30 Apr 06:55 -->

{{ article.published_at | date: format: 'long' }}
<-- April 30, 2019 06:55 -->

You’ll notice that the output of the date filter is just the date itself, without a  element. This can be useful if you need to output just the date into a  tag so you can control the markup around it.

Using the time_tag filter

The time_tag filter converts a timestamp to another date format and outputs an HTML  element. For example, for the same published_at date above, if we used the time_tag filter it would look like this:

{{ article.published_at | time_tag }}
<-- Tue, Apr 30, 2019, 6:55 am -0400 -->

The output inside the HTML element can be customized the same way as we did previously with the date filter. It can take date parameters, and doesn’t affect the value of the datetime attribute set on the tag. For example:

{{ article.published_at | time_tag: '%a, %b %d, %Y' }}
<-- Tue, Apr 30, 2019 -->

You can also alter the datetime attribute for the time_tag by passing a datetime parameter using a custom format:

{{ article.published_at | time_tag: '%a, %b %d, %Y', datetime:'%Y-%m-%d' }}
<-- Tue, Apr 30, 2019 -->

 

Date formatting galore

That’s everything you need to know about date formats in Shopify themes! You might not think it, but there are a lot of places in an online store where you can specify and take advantage of templated date formats. Here are just a few:

  • Blog posts publication dates
  • Email templates
  • Order confirmation
  • User login pages
  • Products (Back in stock on _____ , or In stock after _____ )
  • Footer and Copyright

We hope this post helped you learn how to easily display today’s date in Shopify. You may also want to see our guides on Shopify Plus Pricing - Setup, Apps, Migration, Credit Card Cost - and How To Find And Customize Shopify Page Templates?

If you liked this post, then please share it on social media sites like Facebook, LinkedIn, Twitter etc.

Enjoyed this article? Stay informed by joining our newsletter!

Comments

You must be logged in to post a comment.

About Author

Kishan Mehta is Managing Director and Chief Executive Officer of Shiv Technolab Pvt Ltd, a premier, with 50 + inhouse team company that Develops, Designs, Builds and Operates on extensive development. Mr. Mehta is the key person of "Shiv Technolabs Pvt. Ltd." and leader since the company was founded in 2015. It has been Growing in the evolution from a small company to a Private limited firm whose staff of Developers, IT engineers, designers, Planners, Testers, BDE, Marketers, and Management serve clients virtually anywhere in the world. Mr. Mehta directed the company’s initial public offering Web & Mobile Development, which was one of the 15 Top Web developing Company listings for 2019, and one of the creative USP of developing industry all time. Mr. Mehta is also Chief Technology Officer at CartCoders, which is an affiliated sister company of Shiv Technolabs. The CartCoders' main USP is to focus on providing E-Commerce Services for Complex E-Commerce Solutions. He is the Co-Founder of the CartCoders Committee, E-commerce, and IT Development Industries. In addition, Mr. Mehta has expertise in iOS App Development, as being iOS developer since 2012, His ability to collaborate with cross-functional terms to define, design and ship new features in iOS development, teach interns and learners how to "think out of the box". About Shiv Technolabs Pvt. Ltd. - Shiv Technolabs is one of the best places to get diverse kinds of services such as the creation of Software, Websites, Mobile Applications, etc. They take responsibilities imaginative and guarantee that they meet customer requirements and needs. In the digital community, they claim to make your presence felt so that your websites and mobile applications become so innovative that people could only begin to envy you. Core Services - ✒ Web Development ✒ Mobile Development ✒ Digital Marketing ✒ Quality Assurance ✒ E-commerce Development ✒ UI/UX Development