Nodes/Basic data handling/Time to Unix Timestamp
ComfyUI Node

Time to Unix Timestamp

A DATETIME as Seconds-Since-Epoch — For Systems That Want It

By StableLlama·Created about a year ago·Updated 4 days ago· 48
Time to Unix Timestamp
  • datetime
  • unix_timestamp

Some tools don't want a friendly date string - they want a Unix timestamp: the number of seconds since January 1, 1970 UTC. Time to Unix Timestamp converts a DATETIME to exactly that, as a float. It's the node for the moment your workflow needs to talk to an API, a log system, a naming scheme, or any other thing that thinks in epoch seconds.

How it works

From StableLlama's Basic data handling pack. One required input: datetime - a DATETIME from TimeNow, TimeNowUTC, or TimeParse. The node calls Python's datetime.timestamp() under the hood, which computes seconds since the Unix epoch.

Output: unix_timestamp, a FLOAT. The float part matters - you get fractional seconds (.5, .123456) rather than a rounded integer, which is more precise and also standard for how Unix time is represented in Python. Since the output is a plain FLOAT, it plugs into any node that takes a number, unlike the DATETIME input which only talks to this pack.

There's a natural companion in the same pack: UnixToTime, which runs the conversion in reverse (timestamp → DATETIME). Together they make this pack a complete bridge between human-readable time and epoch seconds.

Where you'd use it

  • API integration - REST calls, cloud storage, and telemetry endpoints often want Unix time in headers or payloads.
  • Stable, sortable identifiers - epoch seconds are a monotonic number, which makes them a clean basis for unique filenames or keys.
  • Interop with other systems - if some other tool in your stack logs or compares in Unix time, convert at the boundary with this node instead of reimplementing the math.

The typical chain: Time Now → Time to Unix → downstream node that expects a number. And since it's a float, you can compare two of them directly for elapsed-time logic without touching the TIMEDELTA nodes at all - if that's more convenient for your downstream tooling.

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

Timezone awareness: a naive DATETIME (which is what TimeParse produces, and what TimeNow gives you) is interpreted as local time when converting to a Unix timestamp, while TimeNowUTC values are unambiguous. If you compare a locally-derived timestamp with one from TimeNowUTC, they'll disagree by your UTC offset - keep both sides of a comparison in the same frame. And remember you're getting seconds since the epoch, not milliseconds - some APIs want ms, and feeding them seconds is a classic off-by-a-thousand bug.

CategoryBasic/time

Inputs (1)

NameTypeDefaultDescription
datetimeDATETIME

Outputs (1)

NameTypeDescription
unix_timestampFLOAT