Skip to content

Instantly share code, notes, and snippets.

@ldd
Created April 8, 2020 18:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ldd/6c9ed66422d7b0b90d8492e09a4ed8ec to your computer and use it in GitHub Desktop.
Save ldd/6c9ed66422d7b0b90d8492e09a4ed8ec to your computer and use it in GitHub Desktop.
jekyll plugin to format date
module Jekyll::CustomFilter
def formatted_date(date)
# date = Time.parse(string_date)
ending = 'th'
case date.day % 10
when 1
ending = 'st'
when 2
ending = 'nd'
when 3
ending = 'rd'
end
date.strftime("%B %-d#{ending}, %Y")
end
end
Liquid::Template.register_filter(Jekyll::CustomFilter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment