Nodes/Basic data handling/Format Time String
ComfyUI Node

Format Time String

Turn a DATETIME Into the Exact String Your Filename Needs

By StableLlama·Created about a year ago·Updated 4 days ago· 48
Format Time String
  • datetime
  • formatted_string
format_string%Y-%m-%d %H:%M:%S

Every time node in this pack hands you a DATETIME object, and a DATETIME is useless until you turn it into text. Format Time String is that step: it takes a DATETIME and a format string, and produces exactly the text you want - "2026-08-16", "14-30-05", "August 2026", your pick. This is the node that makes timestamped filenames possible, and it's the one you'll reach for constantly after Time Now.

How it works

From StableLlama's Basic data handling pack - it's Python's strftime() in a node. Two required inputs:

  • datetime - the DATETIME you got from TimeNow, TimeNowUTC, or TimeParse.
  • format_string (default "%Y-%m-%d %H:%M:%S") - the pattern that controls the output.

The format codes are the standard strftime ones, and you only need a handful:

| Code | Meaning | Example | |------|---------|---------| | %Y | 4-digit year | 2026 | | %m | month, zero-padded | 08 | | %d | day, zero-padded | 16 | | %H | hour (24h), zero-padded | 14 | | %M | minute, zero-padded | 30 | | %S | second, zero-padded | 05 |

Anything else in the format string - dashes, underscores, colons, literal words - passes through unchanged. So "%Y-%m-%d_%H-%M-%S" gives you 2026-08-16_14-30-05, which is the classic collision-free filename.

Output: formatted_string, a plain STRING. And that's the important part - after this node, the value is just text, so it plugs into save paths, filename builders, or any STRING input anywhere.

Why it matters

This is the other half of the filename pipeline: Time Now → Time Format → save node. People build it manually precisely because ComfyUI's built-in %date% template strings in save nodes are unreliable - on Windows they've been reported to clobber outputs or fail with spurious "file doesn't exist" errors, and nobody enjoys losing a finished video. Formatting your own timestamp with this node gives you exact control and a result that behaves like any other string.

Installing it

Search "Basic data handling" in ComfyUI Manager and restart, or:

cd ComfyUI/custom_nodes
git clone https://github.com/StableLlama/ComfyUI-basic_data_handling

Restart and you're set. No dependencies, no models.

Gotchas

The input must be a DATETIME - if you're feeding it a string, that's TimeParse, not this node. And strftime is exact: if your format expects %m but the month is January, you get 01, and if you want a short month name it's %b, not something you type. When the output doesn't match your mental picture, check the code, not the node. One more: %H is 24-hour - if you've ever seen 14:30 and expected 02:30 PM, that's %I with %p for the AM/PM variant.

CategoryBasic/time

Inputs (2)

NameTypeDefaultDescription
datetimeDATETIME
format_stringSTRING%Y-%m-%d %H:%M:%S

Outputs (1)

NameTypeDescription
formatted_stringSTRING