Formatting Dates

Doc Auto Team
Doc Auto Team
  • Updated

There are numerous ways to format dates. We have a flexible system that is able to accommodate most date formats. To learn how to code localized dates in other languages, check out the Localization: Translating Your Code article.

Today's Date

The variable {todaysDate} will always generate the current date. For the purposes of this Help Article, let's assume today is (and always will be) January 5, 2023.

Using the time Function

In order to format the date, we will be using the time function. We can simply use this function without any additional formatting to see the date in its default YYYY-MM-DD format.

Input {todaysDate | time}
Output 2023-01-05

Syntax

{dateVariable | time:'dateElements'}

Using Date Elements

To accommodate a flexible range of date formats, we can also format the date by adding date elements to the code enclosed in 'single quotes':

Syntax Description Appearance
M

Month number

1,2…11,12

MM

Month number with leading 0

01, 02…11,12

MMM

Abbreviated month to 3 letters

Jan, Feb…Nov, Dec

MMMM

Full month name

January, February…November, December

YY

Abbreviated year to last 2 digits

90, 91…19, 20

YYYY

Full year

1990, 1991…2019, 2020

D

Day number

1, 2…30, 31

DD

Day number with leading 0

01, 02…30, 31

dddd

Day of the week

Monday, Tuesday…Saturday, Sunday

Do

Ordinal day

1st, 2nd…30th, 31st

DDD

Day of the year

1, 2, 3…364, 365

DDDo

Ordinal day of the year

1st, 2nd…364th, 365th

NOTE: The date syntax is case sensitive. This means that you must make sure that the formatting is upper or lowercase in accordance with the table above.

Adding Non-Date Elements

You can insert additional words within the time function using [square brackets] within the same 'single quotes' that contain the date elements. Normal punctuation does not require [square brackets].

Input Output
{todaysDate | time} 2023-01-05
{incorporationDate | time:'dddd [the] Do [of] MMM'} Saturday the 29th of Jun
{startDate | time:'Do [day of] MMMM, YYYY'} 19th day of October, 2022