Actions22
- Tool Actions
- Other Tool Actions
- Date Operation Actions
- Text & Formatting Actions
Date Operation → Convert Seconds to Duration
AI-generatedOverview
The node provides a utility to convert a given number of seconds into a human-readable duration format expressed as hours, minutes, and seconds. This is useful in scenarios where you have time durations represented purely in seconds (e.g., elapsed time, video length, or uptime) and want to display or process them in a more conventional HH:MM:SS format.
Practical examples:
- Converting total seconds of a video playback duration into
HH:MM:SSfor display. - Transforming elapsed time in seconds from a timer into a readable format for reports.
- Calculating and formatting durations in automation workflows that handle time tracking.
Properties
| Name | Meaning |
|---|---|
| Seconds | Number of seconds to convert |
Output
The output JSON object contains the following fields:
seconds: The original input number of seconds.hours: The whole number of hours extracted from the input seconds.minutes: The whole number of minutes remaining after extracting hours.remainingSeconds: The leftover seconds after extracting hours and minutes.durationHHMMSS: A string representing the duration formatted asHH:MM:SS, with each component zero-padded to two digits.totalMinutes: Total duration converted entirely into minutes (hours * 60 + minutes).totalHours: Total duration expressed as a decimal number of hours (hours + fractional part from minutes and seconds).
This structured output allows easy use in subsequent workflow steps, either for display or further calculations.
Dependencies
- No external services or API keys are required.
- The node relies on standard JavaScript date/time arithmetic and string formatting.
- No special environment variables or n8n credentials are needed.
Troubleshooting
- Input Validation: The node expects a non-negative number for seconds. If a negative value is provided, it throws an error:
"Seconds must be a positive number". - Common Errors:
- Providing a negative number will cause failure.
- Supplying a non-numeric or missing value may lead to unexpected behavior or errors.
- Resolution:
- Ensure the "Seconds" property is set to a valid, non-negative number before execution.
- Use validation or conditional checks upstream in the workflow to guarantee correct input.
Links and References
- JavaScript Date and Time
- Time Duration Formatting (general reference for duration formats)