ToddN
ToddN

Reputation: 2961

If Statement Based Off DATETIME in Shopify header.liquid

I am trying to add an if-then statement based off a date and time to my header.liquid.

I understand PHP and Javascript but am new to liquid and what shopify will allow.

Basically trying to display an image only during a specific date and time:

If datetime > 2019-09-06 00:00:00 PST AND < 2019-09-09 00:00:00 PST 
THEN {show image}

(Show image from 9/6 PST thru 9/9 PST)

Upvotes: 0

Views: 524

Answers (1)

HymnZzy
HymnZzy

Reputation: 2925

Best way is to use the epoch time tag %s

On Shopify you can convert any date to epoch using the above {{ some_datetime_variable | %s }} and for current time it'd be {{ "now" | %s }}

More details - Dates in liquid

Upvotes: 1

Related Questions