Adding an Ordinal Suffix to a Date

Problem

You want to add an ordinal suffix to a date (“st”, “rd”, “nd”, or “th”).

Solution

{{ now|date("jS") }}    # Example output: 21st

Discussion

The Twig Date filter supports all of the standard PHP DateInterval::format formatting characters.