Timedelta Format
Turn 'how long it took' into a string you'd actually show someone
- value
- STRING
Every once in a while you want to know - and show - how long something took. ComfyUI has no built-in "elapsed time" node, which is why packs keep shipping their own datetime families. JNComfy's version is a small cluster (JN_DatetimeNow, JN_TimedeltaInfo, JN_TimedeltaFormat…), and this node is the one that turns a duration into a readable string. Feed it a TIMEDELTA value and a format, get back a STRING like "Took 00:12:34".
How it works
The format is a template with five placeholders, replaced literally:
%d- days (not zero-padded)%H- hours, zero-padded to 2%M- minutes, zero-padded to 2%S- seconds, zero-padded to 2%f- microseconds, zero-padded to 6
So str_format of "%d days %H:%M:%S" on a duration of one day, 12 hours and change gives "1 days 12:34:56". The placeholders are replaced one pass at a time, left to right - nothing clever like strftime, just five named tokens.
- value - a
TIMEDELTA. This is a type the pack defines; the natural source is theDATETIMEoutput ofJN_DatetimeNowfed into aJN_MathOperationwitha - b(subtracting two datetimes in Python yields a timedelta), or anything else in the pack's datetime family that hands you a duration. - str_format - your template. The
%tokens are the only thing that gets substituted.
Output is a STRING, so it plugs into text nodes, filename builders, or JN_Dump.
Where you'd use it
Mostly logging and labels. Capture JN_DatetimeNow at the start and end of a workflow, subtract, and format the result to print how long the run took - either to the console or baked into an output filename. It's also handy for building human-readable timeout/duration strings out of computed values. If you need the raw numbers instead of a string, JN_TimedeltaInfo breaks a timedelta into separate days, hours, minutes, seconds, microseconds, and total_seconds outputs.
Install
Part of JNComfy. ComfyUI Manager → search "JNComfy" → Install, restart. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/jn-jairo/jn_comfyui
restart, and pip install -r requirements.txt inside the folder if you're installing manually. It's pure Python; the pack's big requirements list (torchaudio, librosa, transformers…) belongs to the audio/face-restore sections and has nothing to do with this node.
Gotchas
- It's not
strftime.%Y,%m,%jand friends will pass through unchanged because they're not in the list of five. If you try%Y-%m-%dyou'll literally see those tokens in the output. That's the top mistake. %dis days, not day-of-month. It's a duration formatter, so%dmeans elapsed days -"2 days"for a two-day timedelta, not "the 2nd".- Getting a
TIMEDELTAinto this node isn't always obvious since none of the pack's nodes output that type directly - the*output of aJN_MathOperationsubtraction (twoJN_DatetimeNowvalues,a - b) is the practical route. Feed it something that isn't a timedelta and the formatting will fail or print garbage.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| value | TIMEDELTA | — | |
| str_format | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| STRING | STRING | — |