ComfyUI > Nodes > Basic data handling > Time Difference

ComfyUI Node: Time Difference

Class Name

Basic data handling: TimeDifference

Category
Basic/time
Author
StableLlama (Account age: 861days)
Extension
Basic data handling
Latest Updated
2026-05-07
Github Stars
0.04K

How to Install Basic data handling

Install this extension via the ComfyUI Manager by searching for Basic data handling
  • 1. Click the Manager button in the main menu
  • 2. Select Custom Nodes Manager button
  • 3. Enter Basic data handling in the search bar
After installation, click the Restart button to restart ComfyUI. Then, manually refresh your browser to clear the cache and access the updated list of nodes.

Visit ComfyUI Online for ready-to-use ComfyUI environment

  • Free trial available
  • 16GB VRAM to 80GB VRAM GPU machines
  • 400+ preloaded models/nodes
  • Freedom to upload custom models/nodes
  • 200+ ready-to-run workflows
  • 100% private workspace with up to 200GB storage
  • Dedicated Support

Run ComfyUI Online

Time Difference Description

Calculates duration between two `DATETIME` points, outputting as `TIMEDELTA` for time-based analysis.

Time Difference:

The TimeDifference node is designed to calculate the duration between two specific points in time, represented as DATETIME objects. This node is particularly useful when you need to determine the time elapsed between two events or timestamps, providing the result as a TIMEDELTA object. This can be beneficial in various scenarios, such as tracking the duration of tasks, calculating age differences, or measuring time intervals in data analysis. By leveraging this node, you can easily obtain precise time differences, which can be further used in scheduling, logging, or any application requiring time-based calculations.

Time Difference Input Parameters:

datetime1

datetime1 is the first DATETIME object representing a specific point in time. This parameter serves as one of the two timestamps between which the time difference is calculated. It is crucial for determining the starting point of the time interval. There are no minimum, maximum, or default values specified for this parameter, as it is expected to be a valid DATETIME object.

datetime2

datetime2 is the second DATETIME object representing another specific point in time. This parameter is used in conjunction with datetime1 to calculate the time difference. It acts as the endpoint of the time interval. Similar to datetime1, there are no predefined limits or default values for this parameter, but it must be a valid DATETIME object.

Time Difference Output Parameters:

timedelta

The output of the TimeDifference node is a TIMEDELTA object, which represents the duration between the two input DATETIME objects. This output is crucial for understanding the time interval in a quantifiable manner, expressed in days, seconds, and microseconds. The TIMEDELTA object can be positive or negative, depending on the order of the input dates, providing flexibility in interpreting past or future time differences.

Time Difference Usage Tips:

  • Ensure that both datetime1 and datetime2 are valid DATETIME objects to avoid errors and obtain accurate results.
  • Use the TIMEDELTA output to perform further calculations, such as adding or subtracting time intervals from other dates.
  • Consider the order of datetime1 and datetime2 if the sign of the TIMEDELTA (positive or negative) is important for your application.

Time Difference Common Errors and Solutions:

Invalid DATETIME object

  • Explanation: This error occurs when one or both of the input parameters are not valid DATETIME objects.
  • Solution: Ensure that the inputs are correctly formatted DATETIME objects before passing them to the node.

TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'NoneType'

  • Explanation: This error indicates that one of the input parameters is None instead of a DATETIME object.
  • Solution: Check that both datetime1 and datetime2 are properly initialized and not None before using them in the node.

Time Difference Related Nodes

Go back to the extension to check out more related nodes.
Basic data handling
RunComfy
Copyright 2025 RunComfy. All Rights Reserved.

RunComfy is the premier ComfyUI platform, offering ComfyUI online environment and services, along with ComfyUI workflows featuring stunning visuals. RunComfy also provides AI Models, enabling artists to harness the latest AI tools to create incredible art.

Time Difference