Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

102
Views
Shopify Liquid show content based on dates

On my shopify store I want to show a html banner in a liquid file from 02/01/2022 - 02/14/2022. It's only for Valentines day orders so I want to auto show the banner just on those dates from the 1st to the 14th.

Any help is greatly appreciated.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

From the Spotify liquid documentation, you can create a conditional code path using the code snippet below:

{% assign start = "2022-01-02" | date: '%s' %}
{% assign end = "2022-02-14" | date: '%s' %}
{% assign today = "now" | date: '%s' %}
{% if  start <= today and today <= end %}
    <h2>Show banner</h2>
{% endif %}

This code will only show the banner within the specified timeframes. You can try it out on the Liquid editor here: https://liquidjs.com/playground.html

about 4 years ago · Juan Pablo Isaza Report

0

Use a simple if-statement. With Date() you get all info that you need.

const date = new Date();

if (date.getDate() > 14 && date.getMonth() === 1 && date.getFullYear() === 2022) {
    document.getElementById('banner').style.display = 'none';
}
<div id="banner">BANNER</div>

Ensure that date.getMonth() is set to 1 for February, since values start with 0.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!