In short
n8n handles dates with the Luxon library. In an expression, {{ $now.toFormat('MM/dd/yyyy HH:mm') }} formats the current date, {{ $json.date.toDateTime().format('LLLL d, yyyy') }} converts then formats a date received as text, and {{ $now.setZone('America/Chicago') }} changes time zone. Always set the instance or workflow time zone: without it, n8n uses America/New_York.
Key takeaways
$nowand$todayare Luxon objects: you format them withtoFormat()and shift them withplus()andminus().- Between two nodes, a date becomes text: convert it with
toDateTime()orDateTime.fromISO()before calculating. format()is an n8n extension available in expressions, not in the Code node, where you usetoFormat().- n8n's default time zone is America/New_York: set
GENERIC_TIMEZONEor the workflow's time zone.
Dates are the number one source of quiet bugs in n8n. An invoice dated the wrong day, a follow-up sent an hour too early, a weekly report that includes the following Monday: nothing fails, but the result is wrong. This guide gathers everything you need to format, convert and calculate dates in n8n, with ready-to-copy expressions for both US and UK formats.
Luxon, n8n's date engine
n8n uses the Luxon JavaScript library for all dates. It is available in expressions (between {{ }}) and in the Code node. n8n's documentation recommends not using JavaScript's native Date object: it does not respect the time zone set for the workflow.
n8n provides two ready-to-use variables:
$now: the current date and time, as a Luxon object;$today: today's date at midnight.
Displayed as-is in a field, they give an ISO timestamp (2026-11-24T08:30:12.123-05:00). For any other format, you format them.
Formatting a date: toFormat()
{{ $now.toFormat('MM/dd/yyyy') }} → 11/24/2026 (US)
{{ $now.toFormat('dd/MM/yyyy') }} → 24/11/2026 (UK)
{{ $now.toFormat('MM/dd/yyyy hh:mm a') }} → 11/24/2026 08:30 AM
{{ $now.toFormat('yyyy-MM-dd') }} → 2026-11-24
{{ $now.toFormat('LLLL d, yyyy') }} → November 24, 2026
{{ $now.setLocale('en-GB').toFormat('d LLLL yyyy') }} → 24 November 2026
{{ $now.toFormat('cccc, LLLL d') }} → Tuesday, November 24
{{ $now.toFormat("'Week' W") }} → Week 48
The most useful tokens
| Token | Meaning | Example |
|---|---|---|
yyyy | 4-digit year | 2026 |
MM / M | 2-digit month / without leading zero | 11 / 11 |
LLLL / LLL | Month spelled out / abbreviated (depends on locale) | November / Nov |
dd / d | 2-digit day of month / without leading zero | 04 / 4 |
cccc / ccc | Weekday spelled out / abbreviated | Tuesday / Tue |
HH / hh + a | Hour 0-23 / hour 1-12 with AM/PM | 14 / 02 PM |
mm, ss | Minutes, seconds | 30, 12 |
W | ISO week number | 48 |
ZZ, ZZZZ | UTC offset, time zone name | -05:00, Eastern Standard Time |
'text' | Literal text, in single quotes | 'on' dd |
Watch the case: MM is the month, mm the minutes. DD in Luxon is not the day of the month but a localized date format. A case mistake gives a wrong date, without any error.
format(), the expression shortcut
In expressions, n8n adds a format() method to dates that accepts the same tokens: {{ $now.format('MM/dd/yyyy') }}. It does not exist in the Code node, which runs an unmodified version of Luxon: calling format() there causes a “format is not a function” error. Use toFormat() everywhere and the question never comes up.
Predefined formats
{{ $now.toISO() }} → 2026-11-24T08:30:12.123-05:00
{{ $now.toISODate() }} → 2026-11-24
{{ $now.toMillis() }} → timestamp in milliseconds
{{ $now.toSeconds() }} → Unix timestamp in seconds
{{ $now.toLocaleString() }} → 11/24/2026 (depends on locale)
Converting text to a date
This is the point that surprises people most: between two nodes, a date becomes text. If one node produces a date and the next reads it, it receives a string. To format it or calculate with it, you have to convert it back.
| Format received | Conversion |
|---|---|
ISO: 2026-11-24T08:30:00Z | {{ $json.date.toDateTime() }} or DateTime.fromISO($json.date) |
US: 11/24/2026 | DateTime.fromFormat($json.date, 'MM/dd/yyyy') |
UK: 24/11/2026 | DateTime.fromFormat($json.date, 'dd/MM/yyyy') |
With time: 11/24/2026 8:30 AM | DateTime.fromFormat($json.date, 'MM/dd/yyyy h:mm a') |
Timestamp in seconds: 1795509000 | DateTime.fromSeconds(Number($json.ts)) |
| Timestamp in milliseconds | DateTime.fromMillis(Number($json.ts)) |
SQL format: 2026-11-24 08:30:00 | DateTime.fromSQL($json.date) |
A full example: a date received from a form in US format, to display spelled out.
{{ DateTime.fromFormat($json.appointment_date, 'MM/dd/yyyy').toFormat('cccc, LLLL d, yyyy') }}
→ Tuesday, November 24, 2026
If conversion fails (unexpected format), Luxon returns an “invalid” date rather than an error. Check it with .isValid to avoid writing “Invalid DateTime” in a customer email.
Calculating with dates
{{ $now.plus({ days: 7 }).toISODate() }} → in 7 days
{{ $today.minus({ months: 1 }).toISODate() }} → a month ago
{{ $now.startOf('month').toISODate() }} → first day of the month
{{ $now.endOf('week').toISODate() }} → Sunday of this week (ISO weeks)
{{ $now.plus({ hours: 2 }).toFormat('h:mm a') }} → in two hours
{{ $now.diff($json.date.toDateTime(), 'days').days }} → days elapsed
{{ $json.date.toDateTime() < $now }} → is the date in the past?
Practical examples
- Invoice due in 30 days (net 30):
{{ $now.plus({ days: 30 }).toFormat('MM/dd/yyyy') }} - Follow up if a quote is more than 7 days old: in an If node,
{{ $now.diff($json.sent_date.toDateTime(), 'days').days > 7 }}. See Automate quote follow-ups. - Previous month's range for a report: start
{{ $now.minus({ months: 1 }).startOf('month').toISODate() }}, end{{ $now.minus({ months: 1 }).endOf('month').toISODate() }}. - Send nothing on weekends:
{{ $now.weekday <= 5 }}(1 = Monday, 7 = Sunday).
Time zones: the real source of bugs
Most “wrong dates” in n8n are time zone problems. Three levels stack up:
- The instance time zone, set by
GENERIC_TIMEZONE. Without it, n8n uses America/New_York. Every schedule and$nowdepend on it, which is fine on the East Coast and wrong everywhere else. - The workflow time zone, in each workflow's settings, which can override the instance's.
- The time zone of incoming data: most APIs return dates in UTC (
Zsuffix).
{{ $json.created_at.toDateTime().setZone('America/Los_Angeles').toFormat('MM/dd/yyyy h:mm a') }}
{{ $json.created_at.toDateTime().setZone('Europe/London').toFormat('dd/MM/yyyy HH:mm') }}
These expressions convert a UTC date received from an API into Pacific or London time before formatting it. Without setZone, it would show several hours off depending on where you are and the season.
On a self-hosted instance, set GENERIC_TIMEZONE and TZ to your time zone (for example America/Chicago or Europe/London) at install time. See n8n environment variables.
Daylight saving time
Twice a year, a schedule at 2:30 AM may not run (the spring-forward change skips that hour) or may run twice (when clocks fall back). The US and the UK switch on different dates, a few weeks apart, so a workflow that syncs data between the two can be off by an hour in between. Avoid scheduling critical workflows between 1 AM and 3 AM local time.
The Date & Time node
If you prefer not to write expressions, the Date & Time node offers the common operations: get the current date, add or subtract a duration, format a date (with a custom format in Luxon tokens), calculate the time between two dates, extract a part (year, month, day), round. It uses Luxon internally, so the same tokens apply.
It has one limit: you cannot calculate and format in the same operation. For “in 7 days, in US format”, chain two nodes, or write a single expression.
In the Code node
// DateTime (Luxon) is available directly in the Code node
const dueDate = DateTime.fromISO($json.invoice_date)
.plus({ days: 30 })
.setZone('America/New_York')
.toFormat('LLLL d, yyyy');
return [{ json: { dueDate } }];
Remember the two differences from expressions: no format() (use toFormat()) and no toDateTime() on strings (use DateTime.fromISO() or fromFormat()).
Dates and monitoring
A date bug almost never makes a workflow fail: it produces a wrong result, or shifts an execution. It is a form of silent failure. Two habits: check the dates produced during setup (compare with a calendar), and monitor the rhythm of scheduled workflows. A daily workflow that, after a time zone change or an update, runs at 3 AM instead of 8 AM, or no longer runs at all, should trigger an alert. That is what Nokto does by comparing each workflow with its schedule and its history.
Frequently asked questions
How do I show today's date in US or UK format in n8n?
In an expression: {{ $now.toFormat('MM/dd/yyyy') }} gives 11/24/2026 (US), and {{ $now.toFormat('dd/MM/yyyy') }} gives 24/11/2026 (UK). For the month spelled out: {{ $now.toFormat('LLLL d, yyyy') }} gives November 24, 2026, and {{ $now.setLocale('en-GB').toFormat('d LLLL yyyy') }} gives 24 November 2026.
How do I convert a string to a date in n8n?
If the string is in ISO format (2026-11-24T08:30:00Z), use {{ $json.date.toDateTime() }} or DateTime.fromISO($json.date). If it follows another format, for example 11/24/2026, use DateTime.fromFormat($json.date, 'MM/dd/yyyy'). A Unix timestamp is converted with DateTime.fromSeconds() or DateTime.fromMillis().
Why are my n8n dates off by a few hours?
Because the instance time zone is not set (n8n uses America/New_York by default), or because the date received is in UTC and displayed without conversion. Set GENERIC_TIMEZONE on the instance or the time zone in the workflow settings, and convert explicitly with setZone() when a date arrives in UTC.
How do I calculate the difference between two dates in n8n?
With Luxon: {{ $now.diff($json.date.toDateTime(), 'days').days }} returns the number of days elapsed. The Date & Time node also offers the “Get Time Between Dates” operation.
What is the difference between format() and toFormat()?
toFormat() is Luxon's native method, available everywhere, including the Code node. format() is a shortcut n8n adds to dates in expressions; it does not exist in the Code node and causes a “format is not a function” error there.