I'm using Liquid with Jekyll to post dates on my band's website (http://longislandsound.com.au)
What I want is to automatically hide old dates, so I don't have to go in and delete them again. I think the best way to do it would be to compare the post date to the current date and only display the post if the date is in the future, but I can't figure out how to do this.
Here is the current code:
<ul id="dates">
{% for post in site.posts reversed %}
<a href="{{post.link}}">
<li>
<div class="date">
<span class="day">{{post.date | date: "%d"}}</span><br />
<span class="month">{{post.date | date: "%b"}}</span>
<span class="week">{{post.date | date: "%a"}}</span>
</div>
<div class="details">
<span class="venue">{{post.venue}}</span><br />
<span class="town">{{post.town}}</span>
</div>
</li>
</a>
{% endfor %}
</ul>
I've tried some if statements, but I can't figure out how to compare the post date to the current date.
Can anyone help?
Based on date-math-manipulation-in-liquid-template-filter and get-todays-date-in-jekyll-with-liquid-markup, you should be able to use a combination of {{'now'}}
or {{site.time}}
and the hard to find unix timestamp date filter | date: '%s'
{% capture nowunix %}{{'now' | date: '%s'}}{% endcapture %}
{% capture posttime %}{{post.date | date: '%s'}}{% endcapture %}
{% if posttime < nowunix %}
...show posts...
Captured numbers may act as strings, not numbers, and can be type cast back to numbers using the following hack:
{% assign nowunix = nowunix | plus: 0 %}