Nodes/comfyui-yanc/Format Datetime String
ComfyUI Node

Format Datetime String

Stamp the Current Time Into a String

By ka-puna·Created 3 years ago·Updated 11 months ago· 12
Format Datetime String
    • STRING
    string_format%Y-%m-%d

    One job: it spits out the current date and time as a string, formatted however you tell it, so you can stick a real timestamp into a filename instead of letting ComfyUI's incrementing counter be the only thing standing between today's batch and yesterday's.

    Under the hood it's about as simple as it looks - datetime.now().strftime(string_format). That means the format field, string_format, uses Python's strftime codes: %Y for a four-digit year, %m for month, %d for day, %H%M%S for hours/minutes/seconds, and so on. The default is %Y-%m-%d, which gets you something like 2026-08-04. It's local system time, not UTC, and - importantly - it re-evaluates on every single queue run rather than caching a value. That's the correct behavior for a timestamp node: you want the actual moment of generation, not a stale value ComfyUI decided not to recompute because "nothing changed."

    Inputs/outputs. Just string_format (required STRING, default "%Y-%m-%d") in, one STRING out. There's no separate time-zone toggle and no output for the raw datetime object - string in, string out, that's the whole node.

    Where this fits: ComfyUI's own Save Image node already supports a %date:yyyy-MM-dd%-style tag baked directly into filename_prefix, so on paper you don't strictly need this node just to get a dated filename. What Format Datetime String buys you is a timestamp as an actual wired value - something you can pipe into Concatenate Strings alongside a checkpoint name pulled from Get Widget Value String, truncate down with Truncate String, and land in Save Image as WEBP's prefix, or just as easily route into a text overlay or a log string elsewhere in the graph. It trades the convenience of a built-in tag for flexibility about where the timestamp actually ends up.

    Installing it. ComfyUI Manager: search "comfyui-yanc," install, restart. By hand:

    cd ComfyUI/custom_nodes
    git clone https://github.com/ka-puna/comfyui-yanc
    

    then restart. Pure Python standard library, no extra dependencies, no models - same as the rest of this pack.

    Troubleshooting. The most common trip-up is mixing up two different templating syntaxes that look similar but aren't: this node's string_format wants Python strftime codes (%Y-%m-%d), while ComfyUI's own built-in filename tags use a different %date:yyyy-MM-dd% style. Paste one into the other's field and you'll get either literal garbage text in your filename or, for a genuinely malformed strftime code, a ValueError that halts the queue. If you're not sure of a code, the Python strftime reference table is the actual source of truth here, not guesswork. Second gotcha, specific to filenames: %H:%M:%S puts literal colons in the output, and colons are illegal in Windows file paths - swap to %H-%M-%S (or similar) if this string is headed for filename_prefix and you're on Windows, otherwise the save can fail downstream in a way that has nothing to do with this node itself.

    Categoryutils

    Inputs (1)

    NameTypeDefaultDescription
    string_formatSTRING%Y-%m-%d

    Outputs (1)

    NameTypeDescription
    STRINGSTRING