cron-parser

Cron expression parser node for n8n workflows with timezone support and next run time calculation

Package Information

Downloads: 40 weeklyĀ /Ā 223 monthly
Latest Version: 0.1.0
Author: Roney Dsilva

Documentation

n8n-nodes-cron-parser

npm version
License: MIT

Parse cron expressions and calculate next/previous run times with timezone support for n8n workflows.

Features

  • ā° Next Run Time - Calculate when a cron job will run next
  • šŸ“… Multiple Run Times - Get multiple upcoming execution times
  • ā®ļø Previous Run Time - Calculate when a cron job last ran
  • āœ… Validation - Validate cron expressions before use
  • šŸŒ Timezone Support - Full IANA timezone database support
  • šŸ“Š Multiple Output Formats - ISO strings, timestamps, or formatted dates
  • šŸ”§ Flexible Input - Use expressions to pull data from previous nodes

Installation

Community Nodes Installation

  1. Go to Settings > Community Nodes in your n8n instance
  2. Select Install
  3. Enter n8n-nodes-cron-parser in the search field
  4. Click Install

Manual Installation

For self-hosted n8n instances:

npm install n8n-nodes-cron-parser

Then restart your n8n instance.

Usage

Get Next Run Time

Calculate when a cron job will execute next:

Input:

  • Cron Expression: 0 0 * * * (daily at midnight)
  • Current Date/Time: 2024-01-15T10:30:00.000Z
  • Timezone: UTC

Output:

{
  "next_run_time": "2024-01-16T00:00:00.000Z",
  "cron_expression": "0 0 * * *",
  "timezone": "UTC",
  "current_date_time": "2024-01-15T10:30:00.000Z"
}

Using with Previous Node Data

You can reference data from previous nodes using n8n expressions:

Cron Expression: {{ $json.cron_expression }}
Current Date/Time: {{ $json.current_date_time }}
Timezone: {{ $json.timezone }}

Example workflow:

// Previous node output
{
  "cron_expression": "0 0 * * *",
  "current_date_time": "2024-01-15T10:30:00.000Z",
  "timezone": "America/New_York"
}

// Cron Parser node will calculate next run time

Get Multiple Next Run Times

Calculate multiple upcoming execution times:

Settings:

  • Cron Expression: 0 * * * * (every hour)
  • Count: 5
  • Current Date/Time: 2024-01-15T10:30:00.000Z

Output:

{
  "next_run_times": [
    "2024-01-15T11:00:00.000Z",
    "2024-01-15T12:00:00.000Z",
    "2024-01-15T13:00:00.000Z",
    "2024-01-15T14:00:00.000Z",
    "2024-01-15T15:00:00.000Z"
  ],
  "count": 5,
  "cron_expression": "0 * * * *",
  "timezone": "UTC"
}

Get Previous Run Time

Calculate when a cron job last executed:

Input:

  • Cron Expression: 0 0 * * *
  • Current Date/Time: 2024-01-15T10:30:00.000Z

Output:

{
  "previous_run_time": "2024-01-15T00:00:00.000Z",
  "cron_expression": "0 0 * * *",
  "timezone": "UTC"
}

Validate Cron Expression

Check if a cron expression is valid:

Input:

  • Cron Expression: 0 0 * * *

Output:

{
  "isValid": true,
  "cronExpression": "0 0 * * *"
}

For invalid expression:

{
  "isValid": false,
  "cronExpression": "invalid cron",
  "error": "Invalid cron expression"
}

Cron Expression Format

This node uses standard 5-field cron format:

ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ minute (0 - 59)
│ ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ hour (0 - 23)
│ │ ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ day of month (1 - 31)
│ │ │ ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ month (1 - 12)
│ │ │ │ ā”Œā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ā”€ day of week (0 - 6) (Sunday to Saturday)
│ │ │ │ │
* * * * *

Common Examples

Expression Description
* * * * * Every minute
0 * * * * Every hour
0 0 * * * Every day at midnight
0 0 * * 0 Every Sunday at midnight
0 0 1 * * First day of every month
*/5 * * * * Every 5 minutes
0 9-17 * * 1-5 Every hour from 9am-5pm on weekdays
0 0 1 1 * January 1st at midnight (yearly)

Timezone Support

The node supports all IANA timezone names:

  • UTC (default)
  • America/New_York
  • America/Los_Angeles
  • Europe/London
  • Europe/Paris
  • Asia/Tokyo
  • Australia/Sydney
  • And many more...

Full timezone list

Output Formats

Choose how to format the output dates:

ISO String (default)

{
  "next_run_time": "2024-01-15T10:30:00.000Z"
}

Unix Timestamp

{
  "next_run_time": 1705318200000
}

Formatted String

{
  "next_run_time": "Mon, 15 Jan 2024 10:30:00 GMT"
}

Options

Include Details

Include additional information about the calculation (enabled by default):

  • Cron expression used
  • Timezone used
  • Current date/time used for calculation

Continue on Error

When enabled, the node will continue processing other items even if one fails, outputting error information instead of stopping the workflow.

Use Cases

1. Schedule Notifications

Calculate when the next maintenance window occurs and send reminders.

2. Job Monitoring

Check if scheduled jobs are running on time by comparing actual run times with expected cron schedules.

3. Report Generation

Calculate multiple upcoming report generation times for scheduling purposes.

4. Multi-timezone Operations

Calculate job execution times across different timezones for global operations.

5. Cron Expression Testing

Validate and test cron expressions before deploying them to production systems.

Example Workflow

[Get Scheduled Jobs] 
    → [Cron Parser - Get Next Run Time] 
    → [Compare with Current Time] 
    → [Send Alert if Overdue]

Error Handling

The node provides detailed error messages:

  • Invalid cron expression: Clear explanation of what's wrong
  • Invalid timezone: Notification if timezone name is not recognized
  • Invalid date format: Help with accepted date formats

Enable "Continue on Error" option to handle errors gracefully and continue processing.

Development

Build

npm install
npm run build

Test

npm test
npm run test:coverage

Lint

npm run lint
npm run lint:fix

Dependencies

License

MIT

Support

Author

Roney Dsilva

Related Packages

Discussion