Nodes/Basic data handling/Parse Time String
ComfyUI Node

Parse Time String

From '2026-08-16' to a Real DATETIME You Can Compute With

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

    TimeFormat turns a DATETIME into text; Parse Time String does the reverse. You give it a string like "2026-08-16 14:30:05" and a format that matches it, and it hands you back a real DATETIME object - one you can subtract from another date, add durations to, or extract components from. Any workflow that takes a date as text and then does math on it needs this node in the middle.

    How it works

    From StableLlama's Basic data handling pack - Python's strptime() wrapped as a node. Two required inputs:

    • time_string - the text you're parsing.
    • format_string (default "%Y-%m-%d %H:%M:%S") - the pattern that describes how the text is laid out.

    The format codes are the same strftime set as TimeFormat: %Y year, %m month, %d day, %H hour, %M minute, %S second. The critical rule: the format must match the string exactly. If your input is "2026/08/16" you need "%Y/%m/%d" - the default dash format will reject it. This is strict matching, with no guessing, which is both the node's strength and its sharpest edge.

    Output: datetime, a DATETIME object. Remember that DATETIME is a custom type defined by this pack, so it only plugs into this pack's time nodes: TimeFormat, TimeExtract, TimeToUnix, TimeAddDelta, TimeSubtractDelta, TimeDifference.

    Where it fits

    • Turning a date from a filename or config into something computable - e.g., parse "2026-08-16" out of a filename, then find out how old it is via TimeDifference.
    • Comparing dates - two parsed DATETIMEs, subtracted, gives you the elapsed duration.
    • Round-tripping - parse a string, adjust it (add a delta), re-format it. String in → DATETIME → math → string out, without ever typing a date by hand.

    The math is the point. A string can't tell you "how many days until this," but the DATETIME it parses into can.

    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 it's available. No dependencies, no models.

    Gotchas

    The strict-format matching is where everyone gets burned. A mismatched format string raises an error, and the error message is strptime's terse one - "time data '2026/08/16' does not match format '%Y-%m-%d %H:%M:%S'". When you see that, it's not a broken node, it's a format mismatch: fix format_string to mirror the text exactly, separators included. Also note it parses naive datetimes - it doesn't infer a timezone, so if you parse "2026-08-16" and compare it to a UTC value from TimeNowUTC, be aware they're in different frames.

    CategoryBasic/time

    Inputs (2)

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

    Outputs (1)

    NameTypeDescription
    datetimeDATETIME