Created
October 11, 2016 06:16
-
-
Save tongrhj/04fa0495915b2bc5e8fe6a611875f292 to your computer and use it in GitHub Desktop.
Liquid Variable to calculate relative days left
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div><span style="font-size: 12px; color: #999999; line-height: 125%;">* {% if offer.expiry_date %}{% assign expiry_timestamp = (offer.expiry_date | date: '%s') %}{% assign now_timestamp = (now | date: '%s') %}{% assign seconds_apart = (expiry_timestamp | minus: now_timestamp) %}{% assign days_apart = (seconds_apart | divided_by: 86400 ) %}Current offer expires on {{ offer.expiry_date | date: '%-d %b %Y' }}<strong>{% if 2 <= days_apart <= 6 %} ({{ days_apart}} days left){% elsif days_apart == 1 %} (tomorrow){% else %} (today){% endif %}</strong>.{% endif %} Offers may change from time to time.</span> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment