Skip to content

Date Formats Reference

Complete reference for date-fns format patterns used in headers and footers.

Usage

Use date formats in the {date:FORMAT} placeholder or with the date element type:

json
// In text content
{ "type": "text", "content": "{date:MMMM d, yyyy}" }

// With date element
{ "type": "date", "format": "MMMM d, yyyy" }

Common Formats

FormatExample OutputUse Case
yyyy-MM-dd2025-06-14ISO date, technical docs
MMMM d, yyyyJune 14, 2025US formal
d MMMM yyyy14 June 2025UK/EU formal
MM/dd/yyyy06/14/2025US short
dd/MM/yyyy14/06/2025UK/EU short
dd.MM.yyyy14.06.2025German/Swiss
yyyy年MM月dd日2025年06月14日Japanese
EEEE, MMMM d, yyyySaturday, June 14, 2025Full date
EEE, MMM dSat, Jun 14Compact
MMM yyyyJun 2025Month and year
Q'Q' yyyy2Q 2025Quarter

Format Tokens

Year

TokenDescriptionExample
yyyy4-digit year2025
yy2-digit year25
yNumeric year2025

Quarter

TokenDescriptionExample
QQuarter number2
QoQuarter ordinal2nd
QQQQuarter abbreviatedQ2
QQQQQuarter full2nd quarter

Month

TokenDescriptionExample
MMonth number6
MMMonth 2-digit06
MMMMonth abbreviatedJun
MMMMMonth fullJune
MMMMMMonth narrowJ

Week

TokenDescriptionExample
wWeek of year24
wwWeek 2-digit24
woWeek ordinal24th

Day of Month

TokenDescriptionExample
dDay of month5
ddDay 2-digit05
doDay ordinal5th

Day of Week

TokenDescriptionExample
EWeekday narrowS
EEWeekday narrowSa
EEEWeekday abbreviatedSat
EEEEWeekday fullSaturday
EEEEEWeekday narrowS

Day of Year

TokenDescriptionExample
DDay of year165
DDDay of year 2-digit165
DDDDay of year 3-digit165

Hour

TokenDescriptionExample
H24-hour14
HH24-hour 2-digit14
h12-hour2
hh12-hour 2-digit02

Minute

TokenDescriptionExample
mMinute5
mmMinute 2-digit05

Second

TokenDescriptionExample
sSecond9
ssSecond 2-digit09

Fraction of Second

TokenDescriptionExample
STenths1
SSHundredths12
SSSMilliseconds123

AM/PM

TokenDescriptionExample
aAM/PMPM
aaAM/PMPM
aaaam/pmpm
aaaaa.m./p.m.p.m.

Timezone

TokenDescriptionExample
zTimezone abbreviatedEST
zzzzTimezone fullEastern Standard Time
ZTimezone offset-0500
ZZTimezone offset-05:00
ZZZZZTimezone offset-05:00:00

Regional Examples

United States

json
// Standard US date
{ "type": "date", "format": "MM/dd/yyyy" }
// → 06/14/2025

// Formal US
{ "type": "date", "format": "MMMM d, yyyy" }
// → June 14, 2025

// Full with day
{ "type": "date", "format": "EEEE, MMMM d, yyyy" }
// → Saturday, June 14, 2025

United Kingdom / Europe

json
// UK short
{ "type": "date", "format": "dd/MM/yyyy" }
// → 14/06/2025

// UK formal
{ "type": "date", "format": "d MMMM yyyy" }
// → 14 June 2025

// European with dots
{ "type": "date", "format": "dd.MM.yyyy" }
// → 14.06.2025

ISO Standard

json
// ISO date
{ "type": "date", "format": "yyyy-MM-dd" }
// → 2025-06-14

// ISO datetime
{ "type": "date", "format": "yyyy-MM-dd HH:mm:ss" }
// → 2025-06-14 14:30:00

// ISO with timezone
{ "type": "date", "format": "yyyy-MM-dd'T'HH:mm:ssZZZZZ" }
// → 2025-06-14T14:30:00-05:00

Time Formats

24-Hour

json
{ "type": "date", "format": "HH:mm" }
// → 14:30

{ "type": "date", "format": "HH:mm:ss" }
// → 14:30:45

12-Hour

json
{ "type": "date", "format": "h:mm a" }
// → 2:30 PM

{ "type": "date", "format": "hh:mm:ss a" }
// → 02:30:45 PM

Combined Date & Time

json
// Standard datetime
{ "type": "date", "format": "MMMM d, yyyy 'at' h:mm a" }
// → June 14, 2025 at 2:30 PM

// Compact datetime
{ "type": "date", "format": "MM/dd/yy HH:mm" }
// → 06/14/25 14:30

// Full datetime
{ "type": "date", "format": "EEEE, MMMM d, yyyy h:mm a" }
// → Saturday, June 14, 2025 2:30 PM

Escaping Text

Use single quotes to include literal text:

json
// Include literal text
{ "type": "date", "format": "'Generated on' MMMM d, yyyy" }
// → Generated on June 14, 2025

// Quarter notation
{ "type": "date", "format": "'Q'Q yyyy" }
// → Q2 2025

// Time with literal "at"
{ "type": "date", "format": "MMM d 'at' h:mm a" }
// → Jun 14 at 2:30 PM

Default Format

If no format is specified, the default is yyyy-MM-dd:

json
// These are equivalent:
{ "type": "date" }
{ "type": "date", "format": "yyyy-MM-dd" }
// → 2025-06-14

In Text Placeholders

json
{
  "type": "text",
  "content": "Report generated {date:MMMM d, yyyy} at {date:h:mm a}"
}
// → Report generated June 14, 2025 at 2:30 PM

Front Matter Example

yaml
---
title: Monthly Report
pdf:
  header:
    right:
      type: date
      format: MMMM yyyy
      font_size: 10px
  footer:
    left_text: "Generated: {date:yyyy-MM-dd HH:mm}"
    center_text: "Page {page} of {pages}"
---

See Also

Released under the MIT License.