Block 1 - On clicking 'execute'
- Type / Role
- n8n-nodes-base.manualTrigger - manualTrigger
- Config choices
- Version 1
This workflow is provided as-is. Please review and test before using in production.
A quick example showing how to get the local date and time into a Function node using moment.js. This relies on the environment variable being correctly configure...
n8n-nodes-base.manualtrigger, n8n-nodes-base.function
This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Trey.
Original n8n.io sourceA quick example showing how to get the local date and time into a Function node using moment.js.
This relies on the GENERIC_TIMEZONE 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:
NODE_FUNCTION_ALLOW_EXTERNAL=moment
For convenience, the Function code is as follows:
const moment = require('moment');
let date = moment().tz($env['GENERIC_TIMEZONE']);
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();
let formatted = date.format('YYYY-MM-DD HH:mm:ss.SSS Z');
return [
{
json: {
utc: date,
year: year,
month: month, // zero-indexed!
day: day,
hour: hour,
minute: minute,
second: second,
millisecond: millisecond,
formatted: formatted
}
}
];
This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.
| Workflow | Get local datetime into Function node using moment.js |
|---|---|
| Complexity | beginner |
| Nodes | 2 |
| Categories | Engineering |
| Author | Trey |
| Published | 01 Oct 2020 |
Use the JSON export at /data/workflows/695/695.json as the source template for this automation.
Open n8n, import the downloaded JSON, and review each node before activating the workflow.
Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.
Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.
Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.
Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.
Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.
A quick example showing how to get the local date and time into a Function node using moment.js. This relies on the environment variable being correctly configure...
Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.
Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Engineering use case.