Databento epoch timestamp converter
Supports Unix timestamps in seconds, milliseconds, microseconds and nanoseconds.
Epoch time, explained
From the engineers behind market data infrastructure at leading HFT firms.
What is epoch time?
The Unix epoch or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z).
Literally speaking, the epoch is Unix time 0 (midnight 1/1/1970), but 'epoch' is often used as a synonym for Unix time.
Formats & limitations
The converter on this page converts timestamps in seconds (10-digit), milliseconds (13-digit) and microseconds (16-digit) to date strings.
Some systems store epoch dates as a signed 32-bit integer, which might cause problems on January 19, 2038. (known as the Year 2038 problem or Y2038).
Date string reference
Date string
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
21:07:47
Milliseconds
1778101667220
Seconds
1778101667
Developer cheatsheet
Quick references for working with epoch timestamps in your stack.
Python
Get current time
import time; time.time()
Date to epoch
import calendar, time; calendar.timegm(time.strptime('2024-11-15', '%Y-%m-%d'))
Epoch to date
import time; time.ctime(1766049974)
C
Get current time
time(NULL);
Date to epoch
struct tm t = {0}; t.tm_isdst = -1; strptime("2024-11-15", "%Y-%m-%d", &t); timegm(&t); // POSIX, UTC
Epoch to date
time_t now = 1766049974; ctime(&now);
C++ (11+)
Get current time
std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()
Date to epoch
std::tm t = {}; std::istringstream ss("2024-11-15"); ss >> std::get_time(&t, "%Y-%m-%d"); timegm(&t); // POSIX, UTC
Epoch to date
std::time_t t = 1766049974; std::ctime(&t);
Java
Get current time
System.currentTimeMillis() / 1000
Date to epoch
java.time.LocalDate.parse("2024-11-15").atStartOfDay(java.time.ZoneOffset.UTC).toEpochSecond()
Epoch to date
java.time.Instant.ofEpochSecond(1766049974).toString()
C#
Get current time
DateTimeOffset.UtcNow.ToUnixTimeSeconds()
Date to epoch
new DateTimeOffset(2024, 11, 15, 0, 0, 0, TimeSpan.Zero).ToUnixTimeSeconds()
Epoch to date
DateTimeOffset.FromUnixTimeSeconds(1766049974).ToString()
Rust
Get current time
SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs()
Date to epoch
chrono::NaiveDate::parse_from_str("2024-11-15", "%Y-%m-%d").unwrap().and_hms_opt(0,0,0).unwrap().and_utc().timestamp()
Epoch to date
chrono::DateTime::from_timestamp(1766049974, 0).unwrap()
Go
Get current time
time.Now().Unix()
Date to epoch
time.Date(2024, 11, 15, 0, 0, 0, 0, time.UTC).Unix()
Epoch to date
time.Unix(1766049974, 0).String()
JavaScript
Get current time
Math.floor(Date.now() / 1000)
Date to epoch
Math.floor(new Date('2024-11-15').getTime() / 1000)
Epoch to date
new Date(1766049974 * 1000).toISOString()
R
Get current time
as.numeric(Sys.time())
Date to epoch
as.numeric(as.POSIXct("2024-11-15", tz="UTC"))
Epoch to date
as.POSIXct(1766049974, origin="1970-01-01", tz="UTC")
MATLAB
Get current time
posixtime(datetime('now', 'TimeZone', 'UTC'))
Date to epoch
posixtime(datetime('2024-11-15', 'TimeZone', 'UTC'))
Epoch to date
datetime(1766049974, 'ConvertFrom', 'posixtime', 'TimeZone', 'UTC')
PostgreSQL
Get current time
SELECT extract(epoch FROM now());
Date to epoch
SELECT extract(epoch FROM timestamptz '2024-11-15 00:00:00+00');
Epoch to date
SELECT to_timestamp(1766049974);
MySQL
Get current time
SELECT UNIX_TIMESTAMP();
Date to epoch
SELECT UNIX_TIMESTAMP(CONVERT_TZ('2024-11-15 00:00:00','+00:00',@@session.time_zone));
Epoch to date
SELECT FROM_UNIXTIME(1766049974);
ClickHouse
Get current time
SELECT toUnixTimestamp(now())
Date to epoch
SELECT toUnixTimestamp(toDateTime('2024-11-15 00:00:00', 'UTC'))
Epoch to date
SELECT toDateTime(1766049974, 'UTC')
SQLite
Get current time
SELECT strftime('%s', 'now');
Date to epoch
SELECT strftime('%s', '2024-11-15 00:00:00');
Epoch to date
SELECT datetime(1766049974, 'unixepoch');
Bash/Shell
Get current time
date +%s
Date to epoch
# GNU coreutils: date -u -d "2024-11-15" +%s # macOS / BSD: date -u -j -f "%Y-%m-%d" "2024-11-15" +%s
Epoch to date
# GNU coreutils: date -u -d @1766049974 # macOS / BSD: date -u -r 1766049974