ssh — guest: ~ connected
guest@ludovic.toinel.com:~$ man epoch

epoch — convert Unix timestamps to dates, and dates to timestamps

SYNOPSIS

epoch [-m] epoch [-s|-m] <timestamp> epoch <date>

DESCRIPTION

Without argument, prints the current Unix time in seconds (in milliseconds with -m) — a single number, ready to be piped or redirected.

Given a timestamp, prints the moment it stands for: in UTC (ISO 8601), in your local time zone, and relative to now ("3 days ago", "in 2 hours"). Seconds and milliseconds are told apart automatically.

Given a date, prints its timestamp in seconds and in milliseconds. Any format your browser can read works; ISO 8601 is the safe one. now is accepted too.

OPTIONS

-s read the number as seconds, whatever its size -m read the number as milliseconds; without argument, print the current time in milliseconds

HOW IT WORKS

Unix time counts the seconds elapsed since 1 January 1970 at 00:00:00 UTC, "the epoch", leap seconds not included. It is a single number with no time zone, which is why logs, databases, APIs and JWT claims use it: the same value means the same instant everywhere.

Many systems (JavaScript, Java, most log pipelines) count milliseconds instead. A number of 100 billion or more is read as milliseconds: as seconds it would land after the year 5138, as milliseconds it is a date from 1973 onward. Use -s or -m when a value falls on the wrong side.

A date without a time zone (2026-01-31 12:00) is read in your local time zone; a date alone (2026-01-31) or one ending in Z is read as UTC. The conversion uses your browser's clock and time zone — nothing is sent.

USE CASES

  • read the timestamp found in a log line, a database row or an API reply;
  • check when a JWT expires (its exp claim is in seconds);
  • get the timestamp of a date for a query or a test fixture;
  • grab the current time for a script: epoch > now.txt.

EXAMPLES

epoch epoch -m epoch 1700000000 epoch 1700000000000 epoch 2026-01-31T12:00:00Z epoch "2026-01-31 12:00"

SEE ALSO

date, cal, cron, jwt