Nodes/comfyui-datetime-format/Datetime Format String
ComfyUI Node

Datetime Format String

Timestamp Your Outputs So a Cleaned-Up Folder Never Eats a Good Image

By Mervent·Created 3 months ago·Updated 3 months ago· 0
Datetime Format String
    • text
    textoutput_%Y_%m_%d_%H_%M

    Out of the box, ComfyUI names your saves ComfyUI_00001_.png - a counter that tells you nothing and, the moment you clean out the output folder, cheerfully restarts at 00001 and overwrites whatever was there. If you've ever lost a generation that way, you already know why you'd reach for this node. DatetimeFormatString is a single widget that spits out the current date and time as a string, so you can stamp a timestamp onto every filename and never wonder which output is which again. It's the "what is a datetime" of ComfyUI, done in the least complicated way possible.

    How it works

    The whole node is one line of Python: datetime.now().strftime(text). You give it a format string, it looks at the system clock of the machine running ComfyUI at the moment the node executes, and returns the formatted result. The default, output_%Y_%m_%d_%H_%M, produces something like output_2026_08_16_19_30.

    Two things follow from that. First, it's evaluated fresh on every run, so each queue execution gets a new timestamp - no stale cache, no restart needed. Second, it's Python's strftime, not Moment.js and not whatever your shell uses. If you type %YYYY expecting a year, you'll get the literal text %YYYY in your filename. The codes you'll actually use: %Y four-digit year, %m month, %d day, %H 24-hour clock, %M minute, %S second, and %f microseconds when you need real uniqueness.

    The one input and one output that matter

    This node has exactly one input: text, a plain string holding the strftime format (the tooltip from the author spells it out: "Use Python strftime codes: %Y %m %d %H %M %S etc."). And exactly one output: text, a STRING with the formatted result.

    So where does it go? The classic setup: right-click the filename_prefix widget on ComfyUI's Save Image node, choose Convert to input, then wire this node's text output into it. Every image you save gets a timestamped prefix. It also feeds any other node that accepts a string - batch-output directories in other packs, logging, even a label you want visible in the workflow. It doesn't touch images, doesn't call anything, doesn't need a key. It just makes strings.

    Installing it

    The pack is tiny and dependency-free - one __init__.py, pure Python standard library, no requirements.txt, no model downloads. This is the rare custom node that cannot break your environment, which in this ecosystem is worth stating plainly.

    Easiest route, ComfyUI Manager: open the Manager, search comfyui-datetime-format, and hit install. Or do it by hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Mervent/comfyui-datetime-format
    

    Then restart ComfyUI. The node shows up in the utils category as "Datetime Format String".

    Where people get burned

    Nothing here is catastrophic, but a few gotchas are worth knowing before they bite:

    • It's server time, not your time. If ComfyUI runs on a remote box, a Colab, or Docker, the stamp is that machine's local clock. Don't rely on it being "your" timezone.
    • One stamp per execution. A whole batch shares the same timestamp. Great for grouping, but if you need every file unique across runs in the same minute, the default %H_%M isn't enough - add %S or %f.
    • Windows hates colons in filenames. Don't throw in %T or a literal :; use the default's underscore style or the file write fails on Windows.

    That's the whole node. It does one thing, does it with no dependencies, and it'll quietly make your output folder readable for years. For a utility this small, that's a win.

    Categoryutils

    Inputs (1)

    NameTypeDefaultDescription
    textSTRINGoutput_%Y_%m_%d_%H_%MUse Python strftime codes: %Y %m %d %H %M %S etc.

    Outputs (1)

    NameTypeDescription
    textSTRING