Report templatesFunctions

formatDate

Format dates into various human-readable formats

Usage

The formatDate function converts date inputs into various formatted string representations based on the specified format parameter.

Syntax

{date | formatDate:format}

Parameters

  • input (string/Date): A date string or Date object to format
  • format (string): The desired output format

Supported Formats

FormatOutput ExampleDescription
"Month""January"Month name only
"Month Year""January 2024"Month name and year
"Day Month Year""15 January 2024"Full date with month name
"DD/MM/YYYY""15/01/2024"Numeric date with slashes
"YYYY""2024"Year only
(other)Original inputReturns input unchanged

Returns

  • Formatted date string based on the specified format
  • Returns input unchanged if undefined or format not recognized

Examples

Month only

{"2024-01-15" | formatDate:"Month"}
// Returns: "January"

Month and year

{"2024-03-20" | formatDate:"Month Year"}
// Returns: "March 2024"

Full date

{"2024-12-25" | formatDate:"Day Month Year"}
// Returns: "25 December 2024"

Numeric format

{"2024-07-04" | formatDate:"DD/MM/YYYY"}
// Returns: "04/07/2024"

Year only

{project.created_at | formatDate:"YYYY"}
// Returns: "2024"

Report dates

{assessment.start_date | formatDate:"Day Month Year"}
// Returns formatted assessment start date

Use Cases

  • Report generation with formatted dates
  • Creating human-readable timestamps
  • Standardizing date display across documents
  • Executive summaries with month/year only
  • International date formatting

Notes

  • Uses browser's locale settings for month names (defaults to en-US)
  • UTC timezone is used for "Day Month Year" format to avoid timezone issues
  • Returns undefined if input is undefined (safe for missing data)