KEEP LEARNING
Build the bigger picture.
The Workflow Engineer connects individual n8n concepts to testing, deployment and running a complete workflow.
Tips > Data, APIs & Webhooks
Different APIs use wildly different date formats -- ISO 8601, Unix timestamps, US format, European format.
n8n bundles the Luxon library globally as DateTime, so you can parse and reformat dates between any API formats without external dependencies. Convert Unix timestamps, ISO 8601 strings, and non-standard layouts, shift time zones, and do date arithmetic directly in expressions, or process a whole batch inside a Code node that requires luxon.
Different APIs use wildly different date formats -- ISO 8601, Unix timestamps, US format, European format. n8n includes the Luxon library globally as DateTime, giving you full control over parsing and formatting without external dependencies.
Real-world example: Your source API (Stripe) returns dates as Unix timestamps. Your destination (a project management tool) expects dd/MM/yyyy format. Meanwhile, your logging database wants ISO 8601.
// Unix timestamp to human-readable
{{ DateTime.fromSeconds($json.created).toFormat('dd/MM/yyyy') }}
// Input: 1710504000 → Output: "15/03/2024"
// ISO string to US format
{{ DateTime.fromISO($json.created_at).toFormat('MM/dd/yyyy hh:mm a') }}
// Input: "2024-03-15T14:30:00Z" → Output: "03/15/2024 02:30 PM"
// Parse a non-standard format
{{ DateTime.fromFormat($json.event_date, 'yyyy-dd-MM').toISO() }}
// Input: "2024-15-03" → Output: "2024-03-15T00:00:00.000+00:00"
// Timezone conversion
{{ DateTime.fromISO($json.utc_time).setZone('America/New_York').toFormat('ff') }}
// Input: "2024-03-15T14:30:00Z" → Output: "Mar 15, 2024, 10:30 AM"
// Relative time calculation
{{ DateTime.fromISO($json.due_date).diff(DateTime.now(), 'days').days.toFixed(0) }}
// Returns number of days until due date
// Add/subtract time
{{ DateTime.now().minus({ days: 7 }).toISO() }}
// Returns ISO timestamp for exactly 7 days agoA practical Code node for batch date transformation:
const items = $input.all();
const { DateTime } = require('luxon');
return items.map(item => ({
json: {
...item.json,
created_display: DateTime.fromSeconds(item.json.created)
.toFormat('dd MMM yyyy'),
created_iso: DateTime.fromSeconds(item.json.created).toISO(),
days_ago: Math.floor(
DateTime.now().diff(DateTime.fromSeconds(item.json.created), 'days').days
)
}
}));Luxon handles timezone-aware parsing, locale formatting, and arithmetic -- covering virtually every date transformation scenario you will encounter.
Related: Flatten Deeply Nested API Responses · Use the HTTP Request Node as a Universal Connector
KEEP LEARNING
The Workflow Engineer connects individual n8n concepts to testing, deployment and running a complete workflow.
APPLY IT TO YOUR SYSTEM
Bring the process, the tools involved and an example of where the current workflow gets stuck.