Skip to content
Tutorials Center
My learning

Topics

Node.js Reference ยท node:sqlite and Runtime Services

Node.js performance.timeOrigin property

Reference for performance.timeOrigin in Node.js: the Unix-epoch millisecond timestamp that performance.now() counts from, and how to turn readings into dates.

performance.timeOrigin is a number: the time, in milliseconds since the Unix epoch, that the process's performance timeline started. Every value returned by performance.now() and every startTime on a performance entry is relative to this moment.

Because now() readings are relative, timeOrigin is how you convert them into real dates, for example to put a timestamp on a log line or to compare timelines from two processes.

NODE
const when = new Date(performance.timeOrigin + performance.now());

Try it

Node.js Converting a relative reading to a date

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Node.js Aligning marks with absolute time

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.

Syntax

NODE
performance.timeOrigin: number

Type: a read-only number in milliseconds, with a fractional part, measured from 1970-01-01T00:00:00Z.

Edge cases: the value is fixed once the process starts. In a worker thread, timeOrigin is the start time of that worker, so it differs from the main thread's value.

Usage notes

  • Combine it with now(): performance.timeOrigin + performance.now() is a high-resolution wall-clock time. It is not guaranteed to equal Date.now() exactly, and it can drift from it if the system clock is changed after startup.
  • Use Date.now() when you need the current wall clock and do not care about sub-millisecond detail. Use now() for intervals.
  • Cross-process timelines: to merge measurements from a parent and a child process or worker, convert each reading to an absolute time with that process's own timeOrigin.
  • Not the process start time in seconds. process.uptime() gives seconds since start; timeOrigin gives the absolute starting moment in milliseconds.
  • Do not display it directly. It is a large floating-point number. Wrap it in new Date(...) for human-readable output.
  • Property, not method. Writing performance.timeOrigin() throws a TypeError.