Nodes/ComfyUI-AutoFlow/Timestamp Generator
ComfyUI Node

Timestamp Generator

A 'now' timestamp that won't break your filenames

By ZXL-Xinram·Created about a year ago·Updated 9 months ago· 4
Timestamp Generator
    • timestamp
    formatYYYYMMDDHHMMSS
    custom_format
    use_utcfalse
    add_millisecondsfalse

    If you've run a ComfyUI workflow with a plain SaveImage twice, you've met the overwrite problem - second run silently replaces the first, and suddenly your "compare these two outputs" plan is a memory. The usual fix is a unique filename, and the cleanest source of uniqueness is the wall clock. AutoFlowTimestampGenerator (shown as "Timestamp Generator") turns the current time into a string you can safely glue into a filename.

    The whole point is the word safely. A plain ISO timestamp like 2025-07-05T01:43:05 contains a colon, and Windows refuses colons in filenames. Every one of this node's twelve presets is filesystem-safe - which is exactly why there's an iso_safe preset that swaps the colon for a dash, and why you'd pick this over just typing a date.

    Mechanically it reads datetime.now() (or UTC if you flip use_utc) and formats it. The presets worth knowing:

    • YYYYMMDDHHMMSS (default) - 20250705014305, compact and sorts correctly.
    • iso_safe - 2025-07-05T01-43-05, closest to ISO 8601 without the colon.
    • readable - 2025Jul05_014305, friendlier for humans, still sortable.
    • timestamp_s / timestamp_ms - Unix epoch, handy for logs or hashing.
    • compact - two-digit year, 250705014305.

    The optional inputs: custom_format (raw Python strftime - it overrides the presets, and if it errors the node logs the problem to the console and falls back to the default format), use_utc (bool), and add_milliseconds (bool).

    The behavior that matters

    This node's IS_CHANGED returns NaN - ComfyUI's "never cache, always re-execute" flag. That's precisely what you want from a "now" node: every run, including every item in a batch, gets a fresh timestamp, so two runs can't collide on the same filename. The flip side is you get no reproducibility - don't use it where the same seed should give the same filename.

    One quirk: add_milliseconds appends milliseconds to the strftime-style presets but is ignored on the timestamp_ms / timestamp_s epoch formats, which are already that precise. Milliseconds make filenames uglier anyway; only switch it on if you're generating more than once a second.

    Wiring it in

    The single output is timestamp (a STRING). Drop it into a save node's filename prefix if the node supports one, or glue it together with the pack's String Concatenator: my_render_ + timestamp gives you my_render_20250705014305.png.

    Install

    Part of the ComfyUI-AutoFlow pack. Use ComfyUI Manager (search ComfyUI-AutoFlow) or clone it:

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

    Restart, and the node appears under the AutoFlow category. No requirements.txt, no models to download - pure Python stdlib. One pack-wide gotcha: the pack's video nodes import opencv-python at load time, so if your environment somehow lacks it, the whole pack (this node included) fails to register. A stock ComfyUI ships OpenCV, so you'll probably never see it.

    CategoryAutoFlow/utilities

    Inputs (4)

    NameTypeDefaultDescription
    formatCOMBOYYYYMMDDHHMMSS12 options: YYYYMMDDHHMMSS, YYYY-MM-DD_HH-MM-SS, YYYYMMDD_HHMMSS, YYYY-MM-DD, YYYYMMDD, HHMMSS, +6
    custom_formatoptSTRING自定义格式字符串,使用Python strftime格式
    use_utcoptBOOLEANfalse是否使用UTC时间
    add_millisecondsoptBOOLEANfalse是否添加毫秒

    Outputs (1)

    NameTypeDescription
    timestampSTRING