Skip to main content
Date and time helpers format and manipulate date values.

formatDate

Formats a date according to a pattern.
{{formatDate date "YYYY-MM-DD"}}
{{formatDate date "MMMM D, YYYY"}}
ArgumentTypeDefaultDescription
datestring/DaterequiredDate to format
formatstring”YYYY-MM-DD”Format pattern

Format Tokens

TokenOutputExample
YYYY4-digit year2024
YY2-digit year24
MMMMFull month nameDecember
MMMShort month nameDec
MM2-digit month12
MMonth number12
DD2-digit day05
DDay number5

Examples

{{formatDate "2024-12-15" "YYYY-MM-DD"}}
Output: 2024-12-15
{{formatDate "2024-12-15" "MMMM D, YYYY"}}
Output: December 15, 2024
{{formatDate "2024-12-15" "MMM D, YYYY"}}
Output: Dec 15, 2024
{{formatDate "2024-12-15" "MM/DD/YYYY"}}
Output: 12/15/2024
{{formatDate "2024-12-15" "D MMMM YYYY"}}
Output: 15 December 2024

formatTime

Formats the time portion of a date.
{{formatTime datetime "24"}}
{{formatTime datetime "12"}}
ArgumentTypeDefaultDescription
datestring/DaterequiredDate/time to format
formatstring”24""12” or “24” hour format
Examples:
{{formatTime "2024-12-15T14:30:00" "24"}}
Output: 14:30
{{formatTime "2024-12-15T14:30:00" "12"}}
Output: 2:30 PM

formatDateTime

Combines date and time formatting.
{{formatDateTime datetime "MMMM D, YYYY" "12"}}
ArgumentTypeDefaultDescription
datestring/DaterequiredDate/time to format
dateFormatstring”YYYY-MM-DD”Date format pattern
timeFormatstring”24""12” or “24” hour format
Examples:
{{formatDateTime "2024-12-15T14:30:00" "MMM D, YYYY" "12"}}
Output: Dec 15, 2024 2:30 PM

now

Returns the current date/time formatted.
{{now}}
{{now "MMMM D, YYYY"}}
ArgumentTypeDefaultDescription
formatstring”YYYY-MM-DD”Format pattern
Examples:
{{now}}
Output: 2024-12-15
{{now "MMMM D, YYYY"}}
Output: December 15, 2024
Generated on: {{now "MMM D, YYYY"}}

addDays

Adds days to a date.
{{addDays date 30}}
{{addDays date -7}}
ArgumentTypeDefaultDescription
datestring/DaterequiredStarting date
daysnumber0Days to add (negative to subtract)
Examples:
{{addDays "2024-12-15" 30}}
Output: 2025-01-14
{{addDays "2024-12-15" -7}}
Output: 2024-12-08 Use case - Due dates:
<p>Invoice Date: {{formatDate invoiceDate "MMM D, YYYY"}}</p>
<p>Due Date: {{formatDate (addDays invoiceDate 30) "MMM D, YYYY"}}</p>

daysBetween

Calculates the number of days between two dates.
{{daysBetween startDate endDate}}
{{daysBetween startDate}}
ArgumentTypeDefaultDescription
date1string/DaterequiredFirst date
date2string/DatenowSecond date
Examples:
{{daysBetween "2024-12-01" "2024-12-15"}}
Output: 14
{{! Days until due date }}
{{daysBetween (now) dueDate}} days remaining

monthName

Returns the full name of the month.
{{monthName date}}
Examples:
{{monthName "2024-12-15"}}
Output: December

dayName

Returns the name of the day of the week.
{{dayName date}}
Examples:
{{dayName "2024-12-15"}}
Output: Sunday

Practical Examples

Invoice Header

<div class="invoice-header">
  <h1>Invoice #{{invoiceNumber}}</h1>
  <div class="dates">
    <p><strong>Invoice Date:</strong> {{formatDate invoiceDate "MMMM D, YYYY"}}</p>
    <p><strong>Due Date:</strong> {{formatDate dueDate "MMMM D, YYYY"}}</p>
  </div>
</div>

Payment Terms

<div class="payment-terms">
  <p>Payment due within 30 days</p>
  <p>Invoice Date: {{formatDate invoiceDate "MMM D, YYYY"}}</p>
  <p>Due Date: {{formatDate (addDays invoiceDate 30) "MMM D, YYYY"}}</p>
</div>
<footer>
  <p>Generated on {{now "MMMM D, YYYY"}} at {{formatTime (now) "12"}}</p>
</footer>

Event Details

<div class="event">
  <h2>{{eventName}}</h2>
  <p class="date">
    {{dayName eventDate}}, {{formatDate eventDate "MMMM D, YYYY"}}
  </p>
  <p class="time">
    {{formatTime startTime "12"}} - {{formatTime endTime "12"}}
  </p>
</div>

Overdue Notice

{{#if (gt (daysBetween dueDate) 0)}}
  <div class="overdue-notice">
    <p>This invoice is {{daysBetween dueDate}} days overdue.</p>
  </div>
{{/if}}

Report Period

<div class="report-header">
  <h1>Monthly Report</h1>
  <p>{{monthName periodStart}} {{formatDate periodStart "YYYY"}}</p>
  <p>{{formatDate periodStart "MMM D"}} - {{formatDate periodEnd "MMM D, YYYY"}}</p>
</div>