Nodes/ComfyUI-AutoFlow/Timestamp Formatter
ComfyUI Node

Timestamp Formatter

Reformat a timestamp you already have, without touching regex

By ZXL-Xinram·Created about a year ago·Updated 9 months ago· 4
Timestamp Formatter
    • formatted_timestamp
    timestamp
    input_format%Y-%m-%d %H:%M:%S
    output_formatYYYYMMDDHHMMSS
    custom_output_format

    The pack's Timestamp Generator is for "now." This one is for everything else - the timestamp that arrived in a filename, in metadata, from an API response, in a spreadsheet row. AutoFlowTimestampFormatter (shown as "Timestamp Formatter") parses an existing string and re-emits it in a different shape. It's the boring, unglamorous normalization step that makes a mixed pile of dates comparable.

    Mechanically it's datetime.strptime(timestamp, input_format) followed by a strftime to the target format. The critical thing to internalize: input_format is Python strftime syntax, and matching is strict. Feed it 2025-07-05 01:43:05 with the default %Y-%m-%d %H:%M:%S and it's happy. Feed it 20250705014305 with that same input format and you'll get your original string back untouched - the node catches the parse error, logs Timestamp format error to the console, and passes the input through rather than crashing.

    That silent-ish pass-through is the trap. If your output looks unchanged, your input_format is wrong, not the node. The good news is you get a console line telling you exactly that.

    Inputs:

    • timestamp - the string you want converted.
    • input_format - the strftime pattern the input must match. Default %Y-%m-%d %H:%M:%S.
    • output_format - a preset from the same filesystem-safe menu as the Generator (seven choices, from YYYYMMDDHHMMSS to readable to iso_safe).
    • custom_output_format - optional raw strftime that overrides the preset.

    The single output is formatted_timestamp (a STRING).

    A concrete example: you've got a file named render_20250705_014305.png. Set input_format to %Y%m%d_%H%M%S, pick readable as the output, and you get 2025Jul05_014305 - good for sorting, logging, or re-keying a list of files that arrived in inconsistent formats. Since the output presets are all filesystem-safe, you can also feed the result straight back into a filename builder.

    Think of the two timestamp nodes as a pair: Generator produces, Formatter normalizes. String together a few mixed-source timestamps through the Formatter and suddenly you can sort or dedupe them instead of squinting at them.

    Install

    It's part of the ComfyUI-AutoFlow pack. Install via ComfyUI Manager (search ComfyUI-AutoFlow) or:

    cd ComfyUI/custom_nodes
    git clone https://github.com/ZXL-Xinram/ComfyUI-AutoFlow
    

    Restart ComfyUI, then find it under the AutoFlow category. No dependencies beyond Python's stdlib datetime, no downloads. The only pack-wide catch is the video nodes importing opencv-python at load time - a stock ComfyUI ships it, but if your environment lacks it, the whole pack (this node included) won't register.

    Troubleshooting

    Output unchanged? Your input_format doesn't match the string - check the console for Timestamp format error and adjust the pattern. Two-digit years need %y, not %Y. Seconds are %S, minutes %M, months %m - the usual strftime mix-ups bite here exactly as hard as they do anywhere else.

    CategoryAutoFlow/utilities

    Inputs (4)

    NameTypeDefaultDescription
    timestampSTRING输入时间戳字符串,支持多种格式
    input_formatSTRING%Y-%m-%d %H:%M:%S输入时间戳的格式
    output_formatCOMBOYYYYMMDDHHMMSS7 options: YYYYMMDDHHMMSS, YYYY-MM-DD_HH-MM-SS, YYYYMMDD_HHMMSS, YYYY-MM-DD, YYYYMMDD, readable, +1
    custom_output_formatoptSTRING自定义输出格式,使用Python strftime格式

    Outputs (1)

    NameTypeDescription
    formatted_timestampSTRING