Display the date, like "May 5th", using Liquid strftime?

Quick Look ๐Ÿ‘€

How to do it

Strftime doesnโ€™t allow you to format a date with a suffix.

So we can build filter to get the correct suffix.

Getting started โœ๏ธ

1
2
3
4
5
6
7
8
9
10
11
12
{% assign day = "now" | date: "%e"| modulo: 10 %}
{%- case day -%}
{%- when 1 -%}
{% assign suffix = 'st' %}
{%- when 2 -%}
{% assign suffix = 'nd' %}
{%- when 3 -%}
{% assign suffix = 'rd' %}
{%- else -%}
{% assign suffix = 'th' %}
{%- endcase -%}
{{ "now" | date: "%e[S] %B, %Y" | replace: '[S]',suffix }}