Skip to main content

Posts tagged with #Dateformat

Recent Posts (Page 1)

Photo by Mick Haupt via Unsplash

Print ordinal date suffixes (1st/2nd/3rd/4th) in GoHugo

Golangs $date.Format is unable to add ordinal suffixes to dates (like 1st, 2nd, 3rd, 4th). Let’s not judge Golang for that. The following is how I remedy this issue: layouts/partials/func/formatOrdinalDate.html go-html-template 1{{- $format := .format -}} 2{{- $date := .date -}} 3{{- $shortened := "th" -}} 4{{- if in (slice 1 21 31) $date.

Back to top
Back Forward