Free Tools
Blog

How to Get the Current Unix Timestamp in Any Language

By Admin Editor · September 28, 2026

A Unix timestamp is the number of seconds since 1 January 1970 at 00:00:00 UTC. It's how databases, APIs, logs and JWTs store time, because it's just a number — no time zones, no formats. Here's how to get the current one in the languages you're most likely to use.

Server racks in a data centre

JavaScript / Node.js

Math.floor(Date.now() / 1000); // seconds
Date.now();                     // milliseconds

Python

import time
int(time.time())        # seconds
time.time_ns() // 1_000_000  # milliseconds

PHP

time();                          // seconds
(int) round(microtime(true) * 1000); // milliseconds

Java

Instant.now().getEpochSecond(); // seconds
System.currentTimeMillis();     // milliseconds

Go

time.Now().Unix()      // seconds
time.Now().UnixMilli() // milliseconds

C#

DateTimeOffset.UtcNow.ToUnixTimeSeconds();
DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();

Bash / Linux / macOS

date +%s

SQL

-- MySQL
SELECT UNIX_TIMESTAMP();
-- PostgreSQL
SELECT EXTRACT(EPOCH FROM NOW())::bigint;
-- SQLite
SELECT strftime('%s', 'now');

A workspace with a laptop and a digital clock

Seconds or milliseconds?

The most common timestamp bug is mixing the two. A quick check:

  • 10 digits (e.g. 1790000000) — seconds. Used by Unix tools, PHP, Python, most APIs and JWT exp claims.
  • 13 digits (e.g. 1790000000000) — milliseconds. Used by JavaScript and Java.

If a date shows up in January 1970, you probably passed seconds where milliseconds were expected. If it's tens of thousands of years in the future, it's the other way round.

Time zones don't apply

A Unix timestamp is always UTC. The same moment has the same timestamp in Tokyo and New York; only the display changes. Convert to local time at the last step, when you show it to a person.

The year 2038 problem

Systems that store timestamps as a signed 32-bit integer overflow on 19 January 2038. Modern languages and databases use 64-bit values, but old embedded devices and legacy database columns may still be affected.

Convert a timestamp to a date

  1. Open the free Timestamp Converter.
  2. Paste a Unix timestamp in seconds, or pick a date and time.
  3. See it as seconds, milliseconds, ISO 8601, UTC and your local time.

FAQ

Does a Unix timestamp include leap seconds? No. Unix time ignores leap seconds, so every day is exactly 86,400 seconds.

Can timestamps be negative? Yes — negative values are dates before 1970.

Try it now

Decode any timestamp with the free Timestamp Converter.

Related reading

See What Is a Unix Timestamp? and How to Decode a JWT.