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.
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.
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
- 1Purchase or download the workflow to get the n8n workflow JSON file.
- 2In your n8n instance, open Workflows and choose "Import from File" (or paste the JSON with Ctrl+V on the canvas).
- 3Open each node marked with a credential warning and connect your own accounts and API keys.
- 4Run the workflow once manually to verify the data flow, then toggle it to Active.
Related Productivity workflows
- Automate Personal Life Management with Telegram and Google Services$14.99
- Automate Google Sheets Cleanup by Removing Duplicates via Profile URLs$4.99
- Automate Google Sheets with AI-Driven Text Generation in n8n$9.99
- Automated Daily Briefing for Executive Communication Management$14.99
- Automate Salon Bookings with AI, Google Calendar, and Email Confirmations$14.99
- Automate Meeting Scheduling with AI via Telegram$9.99
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.