# Formatting a date with suffix (2nd)

**URL:** <https://discourse.gohugo.io/t/formatting-a-date-with-suffix-2nd/5701>\
**Category:** tips & tricks\
**Created:** [March 5, 2017, 6:11pm UTC](https://discourse.gohugo.io/t/formatting-a-date-with-suffix-2nd/5701 "2017-03-05T18:11:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ssddanbrown](https://avatars.discourse-cdn.com/v4/letter/s/f19dbf/32.png) [@ssddanbrown](https://discourse.gohugo.io/u/ssddanbrown)\
**Post date:** [March 5, 2017, 6:11pm UTC](https://discourse.gohugo.io/t/formatting-a-date-with-suffix-2nd/5701/1 "2017-03-05T18:11:14Z")

</div>

Hi all, I couldn’t find anything about formatting a date with a suffix so I thought I’d post my solution for future searchers to find. Using the following template code:

```auto
posted on {{ .Date.Format "2" }}{{ if in (slice 1 21 31) .Date.Day}}st{{ else if in (slice 2 22) .Date.Day}}nd{{ else if in (slice 3 23) .Date.Day}}rd{{ else }}th{{ end }} of {{ .Date.Format "January 2006" }}

```

will give you a result like so:

```auto
posted on 5th of March 2017

```

There may be an easier way to achieve this or ways to clean it up but it seems to work as intended. Hope this helps someone.
