Get today's date in Jekyll with Liquid markup
It didn't work for me either. It appears you've hit a current bug in the Ruby 1.9.3 support. There is a pull request that fixes the bug, but it's not incorporated yet. A workaround is listed, perhaps it will work for you:
{{ site.time | date: '%y' }}
How do I show a Jekyll Collection item on a specific date? (Liquid syntax issue?)
This is happening because the front matter is YAML, and YAML might be more clever than you thought it would.
date: 2020-06-17
Is an actual valid date for YAML.
So if I JSON print such a date
defined in a front matter, then, it would show as a date:
{{ quip.date | json }}
2020-06-17 00:00:00 +0200
So if you want to compare dates from the front matter and from the day, you'll have to format both dates.
{% assign now = "now" | date: "%Y-%m-%d" %}
{% assign show = quip.show | date: "%Y-%m-%d" %}
{% if show == now %}
<p class="fresh-from-the-day">quip.title</p>
{% endif %}
Ordinalize date formatting in Liquid/Jekyll (e.g. 1st, 3rd and 4th)
The Liquid Template Engine that Jekyll uses doesn't offer the ability to ordinalize (e.g. turn "1" into "1st" and "3" into "3rd") out of the box. However, it is possible to use filters and tags to provide that functionality. The snippet below produces the day of month number with an ordanilized string appended. It also removes the leading zero for the first nine days of the month.
{% assign d = page.date | date: "%-d" %}
{% case d %}
{% when "1" or "21" or "31" %}{{ d }}st
{% when "2" or "22" %}{{ d }}nd
{% when "3" or "23" %}{{ d }}rd
{% else %}{{ d }}th
{% endcase %}
For a full date with month, day and year, use this:
{% assign d = page.date | date: "%-d" %}
{{ page.date | date: "%B" }}
{% case d %}{% when "1" or "21" or "31" %}{{ d }}st{% when "2" or "22" %}{{ d }}nd{% when "3" or "23" %}{{ d }}rd{% else %}{{ d }}th{% endcase %},
{{ page.date | date: "%Y" }}
which produces output like:
September 21st, 2013
Note: The code is split onto multiple lines to make it easier to read. It will render fine in HTML but will have extra whitespace in the source code. If that bothers you, simply move everything to one line.
If you are interested in other date formatting options, I create this reference: Jekyll (and GitHub Pages) Liquid Date Formatting Examples
How do I show current age using liquid?
You can either use JS with libraries like moment to compute the birthday client-side, like this:
const pet_birthday_element = document.querySelector("#pet_birthday");
const pet_age_element = document.querySelector("#pet_age");
const pet_age = moment().diff(pet_birthday_element.innerText, 'years');
pet_age_element.innerText = `Your pet is ${pet_age} years old!`;
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js"></script>
Your per birthday is: <span id="pet_birthday">2020-07-10 15:00:00.000</span>
<div id="pet_age"></div>
Related Topics
Best Way to Combine Fragment and Object Caching for Memcached and Rails
Using Typeahead from Twitter Bootstrap in a Form (Formtastic)
Creating Categories on Jekyll Driven Site
How to Read Lines from File into Array
Ruby: How to Chain Multiple Method Calls Together with "Send"
Installing Gem Fails with Permissions Error
Xcode - Configure: Error: No Acceptable C Compiler Found in $Path
How to Make Rails 3 Assets Precompile Faster
Carrierwave Crop Specific Version
What's the Best Way to Parse a Tab-Delimited File in Ruby
How Are Symbols Used to Identify Arguments in Ruby Methods
Generate a Migration File from Schema.Rb