Working with Dates

NAV IS OUTPUT

There are a number of different ways to output Dates with handlebars.

Dates can be formatted to whatever way you need them output by using the dateFormat Helper.

The built-in dateElement Helper allows you to get the Date from a Date element to pass to the dateFormat Helper.

Here are some examples of the dateFormat Helper in action:

Without dateFormat

{{publish element="Date element"}}

Thu, 25 Apr 2024 09:00:05 UTC

With dateFormat (using a Date element)

In this example we use the dateElement Helper to allow us to format dates returned from a Date content element

{{dateFormat (dateElement element="Date element") }}

Thursday, April 25, 2024

With dateFormat (using contentLastModifiedDate)

In this example we use the dateElement Helper to allow us to format dates returned from the contentLastModifiedDate Helper.

{{dateFormat (contentLastModifiedDate) }}

Wednesday, April 3, 2024

With dateFormat value "full"

{{dateFormat (dateElement element="Date element") "full" }}

Thursday, April 25, 2024

With dateFormat value "long"

{{dateFormat (dateElement element="Date element") "long" }}

April 25, 2024

With dateFormat value "medium"

{{dateFormat (dateElement element="Date element") "medium" }}

Apr 25, 2024

With dateFormat value "short"

{{dateFormat (dateElement element="Date element") "short" }}

4/25/24

With dateFormat value "long" and timeFormat value "full"

{{dateFormat (dateElement element="Date element") "long" time="full" }}

April 25, 2024 at 9:00:00 AM Coordinated Universal Time

With dateFormat value "long" and timeFormat value "long"

{{dateFormat (dateElement element="Date element") "long" time="long" }}

April 25, 2024 at 9:00:00 AM UTC

With dateFormat value "long" and timeFormat value "medium"

{{dateFormat (dateElement element="Date element") "long" time="medium" }}

April 25, 2024, 9:00:00 AM

With dateFormat value "long" and timeFormat value "short"

{{dateFormat (dateElement element="Date element") "long" time="short" }}

April 25, 2024, 9:00 AM

With dateFormat value "YYYY/MM/dd hh:mma"

{{dateFormat (dateElement element="Date element") "YYYY/MM/dd hh:mma" }}

2024/04/25 09:00AM

Date Element Test

date: Fri, 20 Sep 2024 09:30:10 UTC