CommandDialog

Epoch Converter

Convert Unix timestamp (seconds elapsed since Jan 1, 1970), to human-readable dates and vice versa, simplifying time-based calculations and comparisons.

Unix Timestamp
Locale Date
RFC 3339
ISO 8601
ISO 9075
ISO 7231
UTC Date

What is Epoch or Unix Timestamp?

Unix time, also known as Epoch time or POSIX time, is a system for describing a point in time as the number of seconds elapsed since the Unix epoch (00:00:00 UTC on 1 January 1970), excluding leap seconds. It serves as a universal standard for time representation in computing, enabling precise time-based calculations, comparisons, and synchronization across systems and applications.

Unix timestamps are widely used in databases, logging systems, APIs, and distributed systems to track events, schedule tasks, and manage time-sensitive operations. However, Unix time is not a true representation of UTC due to its exclusion of leap seconds. Many legacy systems store Unix time as a signed 32-bit integer, which will overflow on 19 January 2038 at 03:14:08 UTC, leading to the Year 2038 problem.

What happens on January 19, 2038?

The Year 2038 problem (Y2038, Epochalypse, or Unix Y2K) is a critical issue for systems using a signed 32-bit integer to store Unix time. These systems cannot represent times beyond 03:14:07 UTC on 19 January 2038, as the maximum value (2,147,483,647 seconds) will be exceeded. When incremented, the timestamp will overflow, flipping to a negative number and causing systems to misinterpret it as 13 December 1901.

This integer overflow can disrupt critical systems in areas such as financial transactions, aviation, healthcare, and infrastructure, where accurate timekeeping is essential. To mitigate this, modern systems are transitioning to 64-bit integers, which can represent time for billions of years into the future. Developers are also encouraged to update legacy systems and adopt robust time-handling libraries to prevent Y2038-related failures.

How to get current Epoch time in different programming languages?

PHP

$epoch = time();

Javascript

var epoch = Math.floor(Date.now() / 1000);

Typescript

let epoch: number = Math.floor(Date.now() / 1000);

C++

#include <chrono>
auto epoch = std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count();

Java

long epoch = System.currentTimeMillis() / 1000;

Rust

use std::time::{SystemTime, UNIX_EPOCH};
let epoch = SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs();

Go

import "time"
epoch := time.Now().Unix()

Swift

import Foundation
let epoch = Int(Date().timeIntervalSince1970)

Bash Shell

epoch=$(date +%s)

C#

long epoch = DateTimeOffset.UtcNow.ToUnixTimeSeconds();

MySQL

SELECT UNIX_TIMESTAMP(NOW());

MATLAB

epoch = posixtime(datetime('now'));

VBA

Dim epoch As Long
epoch = DateDiff("s", "1/1/1970", Now())