Templates / Get local datetime into Function node using moment.js

Get local datetime into Function node using moment.js

Needs changes

by Trey ✓ · 1,986 views · created 2020-10-01 · Engineering

Needs changes. This template uses 1 thing(s) that n8n 3.0 removes: Function (legacy). 1 breaking item(s) found. Static check, last run 2026-12-01.

📬 Weekly n8n 3.0 breakage alerts, free

What this workflow does

This workflow has 2 nodes and runs manually, when you click “Execute workflow”. It uses only n8n's built-in nodes.

How it runs

Trigger: Manually, when you click “Execute workflow”.

  1. Get Local Datetime (Function): runs custom JavaScript (legacy Function node)

Before you upgrade to n8n 3.0

1 thing in this workflow is removed in n8n 3.0. Fix it before you upgrade:

  • Function (legacy) in Get Local Datetime: replace with Code node, mode 'Run Once for All Items'.

Rather not rewrite it? Many of these flows can be rebuilt in Make (free plan).

Published 2020 — 25% of templates published before 2025 need changes for 3.0. See how template age affects 3.0 readiness →

Removed in 3.0Replace with
Function (legacy)
Get Local Datetime
Code node, mode 'Run Once for All Items'

Nodes used (2)

From the author

A quick example showing how to get the local date and time into a Function node using moment.js. This relies on the GENERICTIMEZONE environment variable being correctly configured (see the docs here) NOTE: In order for this to work, you must whitelist the…

Excerpt from Trey's description on n8n.io.

View the original on n8n.io → Check your own copy

Get the weekly “what broke” email

New templates, newly broken ones, and n8n release changes. One short email a week.

Form not loading? Subscribe here.