Get local datetime into Function node using moment.js
n8n template #695Summary
Use templateA 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 moment library for use by setting the following environment variable: NODEFUNCTIONALLOWEXTERNAL=moment For convenience, the Function code is as follows: const moment = require('moment'); let date = moment().tz($env['GENERICTIMEZONE']); let year = date.year(); let month = date.month(); // zero-indexed! let day = date.date(); let hour = date.hours(); let minute = date.minutes(); let second = date.seconds(); let millisecond = date.millisecond(
Hand off to your agent
Prompt
Help me set up the n8n workflow "Get local datetime into Function node using moment.js" (https://n8n.io/workflows/695). It uses: . Import the template JSON into my n8n instance, list every credential I need to create, and walk me through testing it.
Paste into Claude Code and it will do the rest.