Unix Timestamp Converter

Convert between timestamp and date/time (seconds, milliseconds, microseconds)

Current Timestamp: -
-

-
Quick Select:
Google AdSense Ad

What is Unix Timestamp?

A Unix timestamp (also known as Epoch time or POSIX time) is the number of seconds that have elapsed since January 1, 1970 00:00:00 UTC, not counting leap seconds. This point in time is called the "Unix Epoch".

Timestamps are timezone-independent and widely used in:

Seconds vs Milliseconds vs Microseconds

Unit Precision Digits Common Usage
Seconds (s) 1 second 10 digits PHP, MySQL UNIX_TIMESTAMP()
Milliseconds (ms) 0.001 second 13 digits JavaScript, Java
Microseconds (μs) 0.000001 second 16 digits High-precision timing, benchmarks

Get Timestamp in Different Languages

JavaScript

// Seconds Math.floor(Date.now() / 1000); // Milliseconds Date.now(); // Microseconds (approximate) performance.now() * 1000;

Python

import time # Seconds int(time.time()) # Milliseconds int(time.time() * 1000) # Microseconds int(time.time() * 1000000)

Java

// Milliseconds System.currentTimeMillis(); // Seconds System.currentTimeMillis() / 1000L; // Nanoseconds (Java 8+) Instant.now().toEpochMilli();

Go

import "time" // Seconds time.Now().Unix() // Milliseconds time.Now().UnixMilli() // Microseconds time.Now().UnixMicro()

PHP

// Seconds time(); // Milliseconds round(microtime(true) * 1000); // Microseconds round(microtime(true) * 1000000);

MySQL

-- Current timestamp (seconds) SELECT UNIX_TIMESTAMP(); -- Date to timestamp SELECT UNIX_TIMESTAMP('2024-01-01 00:00:00'); -- Timestamp to date SELECT FROM_UNIXTIME(1704067200);

FAQ

Q: Why does Unix time start from 1970?

A: January 1, 1970 is when the Unix operating system was born, and it was chosen as the starting point for computer time. This date is called the "Unix Epoch".

Q: What is the Year 2038 problem?

A: 32-bit systems use a signed 32-bit integer to store timestamps, with a maximum value of 2147483647, which corresponds to January 19, 2038 at 03:14:07 UTC. After this time, it will overflow. Modern 64-bit systems have resolved this issue.

Q: Are timestamps timezone-dependent?

A: No, timestamps are timezone-independent as they represent UTC time. The timezone conversion happens only when displaying the time to users.

Q: Is JavaScript's timestamp in seconds or milliseconds?

A: JavaScript's Date.now() and new Date().getTime() return milliseconds (13 digits). Divide by 1000 to get seconds.

Google AdSense Ad (Article Bottom)