ComfyUI Node

Unix Timestamp

Stamp filenames and log every run

By ArtemKo7v·Created 27 days ago·Updated 2 days ago· 1
Unix Timestamp
    • current
    • saved
    last_value0

    ComfyUI has no idea what time it is, and sometimes that's a problem. Save Image wants a filename, and if you run the same workflow twice in a minute you either overwrite the first file or retype a name every run. Unix Timestamp is the fix: drop it in, wire its current output into your filename builder, and every run gets a fresh, unique timestamp. That's the whole job, and it does it well.

    It's from ArtemKo7v/ComfyUI-UsefulStuffNodes, a small zero-dependency MIT utility pack. Here's the mechanism, and it's worth understanding because the two-output design is the clever part. The node outputs two INTs on every execution:

    • current - int(time.time()), the Unix timestamp (seconds since 1970-01-01 UTC), freshly computed at the moment the node runs.
    • saved - the value the node held before this execution, read from a widget called last_value.

    After the run, a small frontend extension bundled in the pack writes the new current back into last_value. So that widget is write-only bookkeeping that travels with the workflow when you save it - reopen the workflow next week and saved still holds the last timestamp it produced. A freshly added node starts with saved at 0, which is the initial value, not a bug.

    Why is last_value a STRING widget instead of an INT? Because workflow JSON round-trips through JavaScript numbers, and JS precision starts to wobble past 2^53. Storing it as text keeps the integer exact. It's the same trick the sibling Random Long INT node uses, and it's the reason this node can hold a full int64 without silently corrupting it.

    Two things to know before you use it:

    • The node forces itself to rerun every single execution. It does this the standard ComfyUI way - IS_CHANGED returns NaN, which never equals itself, so the cache is always invalid. That's what makes current genuinely fresh each run. The flip side: anything downstream of it re-executes too. Keep it feeding a filename or a logging node, not sitting upstream of a long sampler chain you didn't want rerun.
    • It only fires when the graph runs. No run, no new timestamp - if you want "now" at a specific moment, trigger the queue and read current.

    People have been asking for per-run stamping on r/comfyui for a while - the A1111-style %date:...% filename crowd misses it. Here it's a wire instead of a format string: pull current into whatever filename-builder your workflow already uses, and you get a timestamped file every time, no overwrites.

    Install via ComfyUI Manager (search "ComfyUI-UsefulStuffNodes") or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/ArtemKo7v/ComfyUI-UsefulStuffNodes
    

    Restart ComfyUI, then reload the browser tab - the last_value writeback only works if the frontend extension actually loads, and it only loads after a reload. No dependencies, nothing to download.

    CategoryArtemKo7v

    Inputs (1)

    NameTypeDefaultDescription
    last_valueINT0

    Outputs (2)

    NameTypeDescription
    currentINT
    savedINT