Get Local Datetime in n8n Function Node with Moment.js

Simple workflow to fetch local date/time components in a Function node using moment.js and GENERIC_TIMEZONE env var. Ideal for developers needing timezone-aware timestamps.

n8n
Get Local Datetime in n8n Function Node with Moment.js

This workflow provides a straightforward example of retrieving the local date and time within an n8n Function node using the moment.js library. It starts with a Manual Trigger node and connects to a Function node that requires moment.js (whitelisted via NODE_FUNCTION_ALLOW_EXTERNAL=moment environment variable) and uses the GENERIC_TIMEZONE env var to get accurate local time.

The Function code parses the current moment in the specified timezone, extracting year, month (zero-indexed), day, hour, minute, second, millisecond, and a formatted string. It outputs a JSON object with these values plus the full UTC moment object, making it easy to use in downstream nodes for logging, scheduling, or data processing.

Benefits include quick access to local time without complex node setups, ensuring timezone consistency across workflows, and saving development time. Use cases: timestamping records with local time, conditional logic based on time components, generating reports with proper dates, or integrating into larger automations like notifications or backups that require precise local timing.

Setup requires configuring GENERIC_TIMEZONE in n8n (see docs) and whitelisting moment.js. This is perfect for IT/Dev teams building reliable, timezone-aware automations.

$4.99
Last updated August 22, 2026
30-day money-back guarantee
Instant download
Lifetime updates included

New buyers can create an account from the cart to unlock a controlled $10 first-purchase credit on eligible orders of $25+.

Secure checkout powered by Stripe

Support

How to import this workflow into n8n

  1. 1Purchase or download the workflow to get the n8n workflow JSON file.
  2. 2In your n8n instance, open Workflows and choose "Import from File" (or paste the JSON with Ctrl+V on the canvas).
  3. 3Open each node marked with a credential warning and connect your own accounts and API keys.
  4. 4Run the workflow once manually to verify the data flow, then toggle it to Active.

Related Productivity workflows

More from Jordi Faber

Need this deployed? We'll set it up for you.

Our automation experts deploy this workflow in your stack, connect your accounts, and verify it works — or build a custom solution from scratch.