Date functions
Date
Format date value.
{% date({dateString}, {timezone}, {addDays}, {outputFormat}, {inputFormat}) %}
Examples of the function "Date":
- Display current time
{% date('now') %}
- Specify timezone
{% date({dateValue}, 'UTC') %}
- Specify output format
{% date({dateValue}, 'UTC', 0, 'd/m/Y') %}
- Specify output and input format
{% date({dateValue}, 'UTC', 0, 'd/m/Y', 'm/d/Y') %}
Datetime
Format datetime value.
{% datetime({datetimeString}, {timezone}, {addDays}, {outputFormat}, {inputFormat}) %}
Examples of the function "Datetime":
- Display current time
{% datetime('now') %}
- Specify timezone
{% datetime({dateValue}, 'UTC') %}
- Specify output format
{% datetime({dateValue}, 'UTC', 0, 'd/m/Y H:i:s') %}
- Specify output and input format
{% datetime({dateValue}, 'UTC', 0, 'd/m/Y H:i:', 'm/d/Y H:i:') %}
Y-m-d\TH:i:s
Date difference
The date_diff function calculates a difference between two dates. You can also specify the {inputFormat} to hint date format. If date strings use known format then it is handled automatically.
{% date_diff({datetimeString}, {datetimeString}, {inputFormat}) %}
You can use date('now') function as the date value to find difference between today and another date.
{% date_diff(date('now'), '2021-09-15', 'Y-m-d') %}
Format | Description | Example Output |
|---|---|---|
Day |
|
|
| The day of the month (two digits, leading zeros) | 01 to 31 |
| A textual representation of a day (three letters) | Mon through Sun |
| The day of the month without leading zeros | 1 to 31 |
| A full textual representation of the day | Sunday through Saturday |
| ISO-8601 numeric representation of the day (1 = Monday, 7 = Sunday) | 1 to 7 |
| English ordinal suffix for the day of the month (2 characters: st, nd, rd, or th) | 1st, 2nd, 3rd |
| Numeric representation of the day (0 = Sunday, 6 = Saturday) | 0 to 6 |
| The day of the year | 0 through 365 |
Week |
|
|
| ISO-8601 week number of year (weeks starting on Monday) | 01 to 53 |
Month |
|
|
| A full textual representation of a month | January through December |
| Numeric representation of a month (two digits, leading zeros) | 01 to 12 |
| A short textual representation of a month (three letters) | Jan through Dec |
| Numeric representation of a month (without leading zeros) | 1 to 12 |
| The number of days in the given month | 28 to 31 |
Year |
|
|
| Whether it's a leap year (1 if it is a leap year, 0 otherwise) | 0 or 1 |
| ISO-8601 year number | 2023 |
| A full numeric representation of a year (four digits) | 2023 |
| A two-digit representation of a year | 23 |
Time |
|
|
| Lowercase am or pm | am, pm |
| Uppercase AM or PM | AM, PM |
| Swatch Internet time | 000 to 999 |
| 12-hour format of an hour (no leading zeros) | 1 to 12 |
| 24-hour format of an hour (no leading zeros) | 0 to 23 |
| 12-hour format of an hour (two digits, leading zeros) | 01 to 12 |
| 24-hour format of an hour (two digits, leading zeros) | 00 to 23 |
| Minutes with leading zeros | 00 to 59 |
| Seconds, with leading zeros | 00 to 59 |
| Microseconds | 654321 |
Timezone |
|
|
| Timezone identifier | UTC, GMT, Europe/Paris |
| Whether the date is in Daylight Savings Time (1 if DST, 0 otherwise) | 0 or 1 |
| Difference to Greenwich time (GMT) in hours | +0200 |
| Difference to Greenwich time (GMT) with colon between hours and minutes | +02:00 |
| Timezone abbreviation | EST, MDT |
| Timezone offset in seconds (west of UTC is negative, east of UTC is positive) | -43200 to 50400 |
Full Date/Time |
|
|
| ISO-8601 date | 2023-01-14T23:59:59+00:00 |
| RFC 2822 formatted date | Sat, 14 Jan 2023 23:59:59 +0000 |
| Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) | 1673740799 |
Related articles you may find helpful
- Date component
- How to add page numbers?
- Is it possible to conditionally change the component style or hide the component?
Updated on: 04/09/2025
Thank you!
