Time Delta to Milliseconds
Time Delta to Milliseconds
- delta
- milliseconds
Ever wanted to know how long a render actually took, in a number your workflow can use? That's the wall this node exists to knock down. ComfyUI will happily hand you a duration as a TIMEDELTA object - Python's way of saying "some span of time, without units attached" - and then the node you want to feed it to only accepts a plain INT or FLOAT. A TIMEDELTA isn't a number. TimeDeltaToMilliseconds is the bridge: one input in, one integer out, with the duration expressed in milliseconds.
Where does a TIMEDELTA even come from?
Here's the gotcha that trips everyone up: ComfyUI's core has no time types at all. TIMEDELTA is a custom type registered by this pack (Basic data handling), which means it can only be produced by two siblings in the same pack:
- TimeDelta - build a duration by hand from days, hours, minutes, seconds, milliseconds, and so on.
- TimeDifference - subtract two
DATETIMEobjects and get the elapsed span.
The classic setup is a poor-man's stopwatch: a TimeNow node at the start of the graph, another TimeNow at the end, TimeDifference wired between them, and this node converting the result into something you can actually print or save.
What it does
The entire mechanism is one line of Python:
round(delta.total_seconds() * 1000)
It takes a single required input, delta (type TIMEDELTA), and returns one output, milliseconds (type INT). Two details are worth knowing. First, it rounds to the nearest millisecond, so sub-millisecond precision is gone - completely irrelevant for timing generations, but good to know. Second, negative deltas pass through as negative numbers. Subtract your two timestamps in the wrong order and you get -12847 ms, no error, just math you didn't want.
What to wire the output into
An INT is the lingua franca of ComfyUI plumbing. Feed milliseconds into a text node to show "Render took 12,847 ms" in the UI, into a math node if you want to scale it, or into a save-to-file node to log timings across runs. Anything that takes an INT will take this.
Install
ComfyUI Manager → search "Basic data handling" → Install → restart ComfyUI. Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling
Then restart ComfyUI. That's the whole install: no model downloads, no dependencies. The pack's requirements.txt is empty, which in the world of ComfyUI custom nodes is a genuine blessing - no version conflicts to babysit.
Troubleshooting
- "Cannot connect" on the delta socket - the
TIMEDELTAinput only accepts TIMEDELTA. If you're feeding it a DATETIME or a string, that's the error. Route it through TimeDifference (two datetimes) or TimeDelta (build the duration) first. - Negative output - check the argument order in TimeDifference; it computes
datetime1 - datetime2. - "Missing node" when loading a workflow - this whole pack installs in one shot via Manager, so that's the fix.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| delta | TIMEDELTA | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| milliseconds | INT | — |