Skip to content

Date Formatting ​

The Markdown PDF extension uses date-fns for date formatting. This gives you powerful, flexible control over how dates appear in your headers and footers.

Basic Usage ​

Use the {date:FORMAT} placeholder in text elements:

json
{
  "header": {
    "right": {
      "type": "text",
      "content": "{date:MMMM d, yyyy}"
    }
  }
}

Or with the dedicated date element type:

json
{
  "header": {
    "right": {
      "type": "date",
      "format": "MMMM d, yyyy"
    }
  }
}

Both produce: June 14, 2025

Common Formats ​

FormatExampleUse Case
yyyy-MM-dd2025-06-14ISO date, sorting
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

Format Tokens ​

Year ​

TokenOutputExample
yyyy4-digit year2025
yy2-digit year25

Month ​

TokenOutputExample
MMMMFull month nameJanuary
MMMAbbreviated monthJan
MM2-digit month01
MMonth number1

Day ​

TokenOutputExample
dd2-digit day05
dDay number5
EEEEFull weekdayMonday
EEEAbbreviated weekdayMon
EShort weekdayM

Time ​

TokenOutputExample
HH24-hour hour (2-digit)14
H24-hour hour14
hh12-hour hour (2-digit)02
h12-hour hour2
mmMinutes (2-digit)05
mMinutes5
ssSeconds (2-digit)09
sSeconds9
aAM/PMPM

Other ​

TokenOutputExample
QQuarter2
QoQuarter (ordinal)2nd
wWeek of year24

Preset Formats ​

For convenience, you can use named presets:

PresetFormatExample
isoyyyy-MM-dd2025-06-14
usMM/dd/yyyy06/14/2025
us-longMMMM d, yyyyJune 14, 2025
eudd/MM/yyyy14/06/2025
eu-longd MMMM yyyy14 June 2025
eu-dotdd.MM.yyyy14.06.2025

Examples ​

US Format ​

json
{
  "header": {
    "right_text": "{date:MMMM d, yyyy}"
  }
}

→ June 14, 2025

European Format ​

json
{
  "header": {
    "right_text": "{date:d MMMM yyyy}"
  }
}

→ 14 June 2025

ISO Date ​

json
{
  "footer": {
    "left_text": "Generated: {date:yyyy-MM-dd}"
  }
}

→ Generated: 2025-06-14

With Time ​

json
{
  "footer": {
    "right_text": "{date:yyyy-MM-dd HH:mm}"
  }
}

→ 2025-06-14 14:30

Day of Week ​

json
{
  "header": {
    "right_text": "{date:EEEE, MMMM d, yyyy}"
  }
}

→ Saturday, June 14, 2025

Quarter ​

json
{
  "footer": {
    "left_text": "Q{date:Q} {date:yyyy}"
  }
}

→ Q2 2025

Date Element Type ​

Use the date element type for standalone date display:

json
{
  "header": {
    "right": {
      "type": "date",
      "format": "MMMM d, yyyy",
      "font_size": "10px",
      "color": "#666"
    }
  }
}

Date Element Properties ​

PropertyTypeDescription
type"date"Element type
formatstringdate-fns format string
font_sizestringCSS font size
font_weightstring|numberCSS font weight
colorstringCSS color
stylestringAdditional inline CSS

Combining with Other Placeholders ​

Date placeholders work alongside other placeholders:

json
{
  "footer": {
    "center_text": "{title} • {date:MMMM yyyy} • Page {page}"
  }
}

→ My Report • June 2025 • Page 3

Default Format ​

If you use {date} without a format, it defaults to ISO format (yyyy-MM-dd):

json
{
  "footer": {
    "left_text": "{date}"
  }
}

→ 2025-06-14

Time Zones ​

Dates are rendered using the local time of the machine running the export. The current time is captured at the start of the export and used consistently throughout.

Front Matter Example ​

yaml
---
title: Quarterly Report
pdf:
  header:
    height: 15mm
    left_text: "Acme Corp"
    right:
      type: date
      format: MMMM d, yyyy
  footer:
    center_text: "{date:Q}Q {date:yyyy} Report • Page {page} of {pages}"
---

Next Steps ​

Released under the MIT License.