See llms.txt for all machine-readable content.

Back to Templates

Get the local date and time with the Code node

Read the current date and time in the workflow time zone with the n8n Code node. The workflow returns the UTC timestamp, local calendar fields and a formatted local timestamp that includes the UTC offset. The month is zero-indexed.

Set the time zone in the workflow settings, then execute the manual trigger. The Code node uses the built-in $now value.

const date = $now; return [{json: { utc: date.toUTC().toISO(), year: date.year, month: date.month - 1, day: date.day, hour: date.hour, minute: date.minute, second: date.second, millisecond: date.millisecond, formatted: date.toFormat('yyyy-MM-dd HH:mm:ss.SSS ZZ') }}];