Get Previous Run Time
AI-generatedSummary
Calculate the previous run time from a cron expression.
Inputs
- cronExpression (required) — The cron expression to parse. Supports standard 5-field format (minute, hour, day, month, weekday). Default: '0 0 * * *'.
- currentDateTime — The date/time to calculate from. Accepts ISO strings, timestamps, or any valid date string. Leave empty to use current time. Default: '' (current time).
- timezone — The timezone for calculation. Use IANA timezone names (e.g., America/New_York, Europe/London) or UTC. Default: 'UTC'.
- options — Output formatting and error handling options.
Output shape
object
Output includes 'previous_run_time' formatted per outputFormat. When includeDetails is true (default), also includes 'cron_expression', 'timezone', and 'current_date_time'. Invalid cron expressions throw a NodeOperationError unless continueOnError is true.
Examples
Example 1: Calculate previous run time at midnight UTC
cronExpression: '0 0 * * *', outputFormat: 'iso' (default), includeDetails: true, currentDateTime: '', timezone: 'UTC' returns: { previous_run_time: '2024-01-14T10:00:00.000Z', cron_expression: '0 0 * * *', timezone: 'UTC', current_date_time: '2024-01-15T10:30:00.000Z' }