Epoch timestamp converter

Convert Unix timestamps and date strings with one input that automatically detects any format.

URL shortcut

Drop an epoch timestamp or date string into the URL for instant conversion.

epoch.to/

17777716000000000

Chrome extension

Highlight timestamps to convert from any web page.

Epoch CLI

Convert from your terminal with an open-source CLI.

$ epoch 1585796573

About Unix time

Unix timestamps give computer systems a common numerical representation of time, across formats and time zones.

What is Unix time?

Unix time represents a point in time as the number of seconds since January 1, 1970 at 00:00:00 UTC, excluding leap seconds. A Unix timestamp of 0 corresponds to 1970-01-01T00:00:00Z.


In practice, “epoch time,” “Unix time,” “POSIX time,” and “Unix timestamp” are often used interchangeably.

What formats do Unix timestamps use?

Unix timestamps can be expressed at different precisions. This converter supports seconds (10 digits), milliseconds (13), microseconds (16), and nanoseconds (19).


Number of digits is a useful shorthand, but it isn’t part of the Unix timestamp standard and can vary for dates far from the present, including those before September 2001.

Time interval reference

Timeframe

Seconds

1 hour

3,600

1 day

86,400

1 week

604,800

1 month (30.44 days)

2,629,743

1 year (365.24 days)

31,556,926

06:00:56

Milliseconds

1789624856205

Seconds

1789624856

Why we built epoch.to

A better timestamp converter, shaped by years of engineering and market data experience.

Between electronic market making and building market data infrastructure at Databento, our team has spent many years working with timestamps.

We built this converter for ourselves, because none of the existing online tools handled the cases we ran into every day.

Along the way, we added features around things we do most: copying values quickly, jumping to market session boundaries, and handling timezones across major exchanges.

It’s become part of our daily workflows, and we hope you’ll find it as useful as we have.

Developer cheatsheet

Quick references for working with epoch timestamps in your stack.

.py

Python (3.3+)

Get current epoch

import time; time.time()

Datetime to epoch

dt.timestamp()

Epoch to datetime

import datetime; datetime.datetime.fromtimestamp(1766049974.123456, tz=datetime.timezone.utc)

.c

C (C11 + POSIX)

Get current epoch

struct timespec now; timespec_get(&now, TIME_UTC);

Datetime to epoch

timegm(&dt);

Epoch to datetime

time_t epoch = 1766049974; struct tm dt; gmtime_r(&epoch, &dt);

.cpp

C++ (C++20)

Get current epoch

std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count();

Time point to epoch

tp.time_since_epoch().count();

Epoch to time point

std::chrono::sys_time<std::chrono::nanoseconds> tp{std::chrono::nanoseconds(1766049974000000000)};

.java

Java (8+)

Get current epoch

ChronoUnit.NANOS.between(Instant.EPOCH, Instant.now());

Datetime to epoch

ChronoUnit.NANOS.between(Instant.EPOCH, dt.toInstant(ZoneOffset.UTC));

Epoch to datetime

LocalDateTime.ofInstant(Instant.ofEpochSecond(0, 1766049974000000000), ZoneOffset.UTC);

.cs

C# (.NET Core 2.1+)

Get current epoch

(DateTime.UtcNow - DateTime.UnixEpoch).TotalSeconds

Datetime to epoch

(dt - DateTime.UnixEpoch).TotalSeconds

Epoch to datetime

DateTime.UnixEpoch.AddTicks((long)Math.Round(1766049974 * 1e7))

.rs

Rust (chrono 0.4.31+)

Get current epoch

std::time::SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_nanos()

Datetime to epoch

dt.and_utc().timestamp_nanos_opt().unwrap()

Epoch to datetime

chrono::Utc.timestamp_nanos(1766049974000000000).naive_utc()

.go

Go (standard library)

Get current epoch

time.Now().UnixNano()

Datetime to epoch

dt.UnixNano()

Epoch to datetime

time.Unix(0, 1766049974000000000).UTC()

.js

JavaScript (ES5+)

Get current epoch

Date.now() / 1000

Datetime to epoch

dt.getTime() / 1000

Epoch to datetime

new Date(1766049974.123 * 1000)

.r

R (base R)

Get current epoch

as.numeric(Sys.time())

Datetime to epoch

as.numeric(ct)

Epoch to datetime

as.POSIXct(1766049974.123456, origin="1970-01-01", tz="UTC")

.m

MATLAB (R2014b+)

Get current epoch

posixtime(datetime('now', 'TimeZone', 'UTC'))

Datetime to epoch

posixtime(dt)

Epoch to datetime

datetime(1766049974.123456789, 'ConvertFrom', 'posixtime', 'TimeZone', 'UTC')

.sql

PostgreSQL

Get current epoch

SELECT extract(epoch FROM now());

Datetime to epoch

SELECT extract(epoch FROM dt);

Epoch to datetime

SELECT to_timestamp(1766049974.123456) AT TIME ZONE 'UTC';

.sql

MySQL (5.6+)

Get current epoch

SET time_zone = '+00:00'; SELECT UNIX_TIMESTAMP(NOW(6));

Datetime to epoch

SET time_zone = '+00:00'; SELECT UNIX_TIMESTAMP('2024-11-15 00:00:00.123456');

Epoch to datetime

SET time_zone = '+00:00'; SELECT FROM_UNIXTIME(1766049974.123456);

.sql

ClickHouse (20.1+)

Get current epoch

SELECT toUnixTimestamp64Nano(now64(9));

Datetime to epoch

SELECT toUnixTimestamp64Nano(toDateTime64('2024-11-15 00:00:00', 9, 'UTC'));

Epoch to datetime

SELECT fromUnixTimestamp64Nano(1766049974000000000, 'UTC');

.sql

SQLite (3.42+)

Get current epoch

SELECT unixepoch('subsec');

Datetime to epoch

SELECT strftime('%s', '2024-11-15 00:00:00');

Epoch to datetime

SELECT datetime(1766049974, 'unixepoch');

.sh

Shell (GNU coreutils)

Get current epoch

date -u +%s.%N

Datetime to epoch

date -u -d "2024-11-15" +%s.%N

Epoch to datetime

date -u -d @1766049974.123 +"%Y-%m-%d %H:%M:%S.%N"

.sh

Shell (macOS / BSD)

Get current epoch

date -u +%s

Datetime to epoch

date -j -u -f "%Y-%m-%d %H:%M:%S" "2024-11-15 13:23:01" +%s

Epoch to datetime

date -u -r 1766049974 +"%Y-%m-%d %H:%M:%S"

Frequently asked questions

Unix time conversions

Timestamping in practice

Accuracy, precision, and resolution

Clock synchronization and latency

Leap years and leap seconds