The Unix timestamp converter that tells you what you are looking at.

 

Code reference

Convert Unix epoch to date in any language

The tool above converts epoch ↔ date in your browser. The reference below shows how to do the same conversions in code, plus the lookup tables most often needed when working with Unix timestamps. Twenty languages and database engines; copy-and-paste ready.

Time interval reference

IntervalSeconds
1 minute60
1 hour3,600
1 day86,400
1 week604,800
1 month (~30.437 days, average)2,629,743
1 quarter (~91.31 days, average)7,889,229
1 year (365.25 days, Julian)31,557,600
1 decade315,576,000

Timestamp unit detection

The number of digits in a timestamp tells you which unit it's in. Epochr above auto-detects from the magnitude of the input.

DigitsUnitRange covered
10SecondsSep 9, 2001 → Nov 20, 2286
13MillisecondsSame range, in ms
16MicrosecondsSame range, in μs
19NanosecondsSame range, in ns

A 13-digit number that looks like seconds is almost certainly milliseconds. The most common silent bug in timestamp code is mixing the two.

Compiled languages

LanguageGet current epoch (seconds)Convert epoch to date
Ctime(NULL)ctime(&epoch)
C++ (chrono)std::chrono::duration_cast<std::chrono::seconds>(std::chrono::system_clock::now().time_since_epoch()).count()std::ctime(&epoch)
Gotime.Now().Unix()time.Unix(epoch, 0)
RustSystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs()chrono::DateTime::from_timestamp(epoch, 0).unwrap()
JavaSystem.currentTimeMillis() / 1000new java.util.Date(epoch * 1000)
KotlinSystem.currentTimeMillis() / 1000java.util.Date(epoch * 1000)
SwiftInt(Date().timeIntervalSince1970)Date(timeIntervalSince1970: TimeInterval(epoch))
C# / .NETDateTimeOffset.UtcNow.ToUnixTimeSeconds()DateTimeOffset.FromUnixTimeSeconds(epoch).UtcDateTime

Scripting languages

LanguageGet current epoch (seconds)Convert epoch to date
Pythonint(time.time())datetime.fromtimestamp(epoch, tz=timezone.utc)
RubyTime.now.to_iTime.at(epoch).utc
Perltimegmtime(epoch)
PHPtime()gmdate('c', epoch)
Luaos.time()os.date('!%c', epoch)
Bash (Linux, GNU date)date +%sdate -u -d @epoch
Bash (macOS, BSD date)date +%sdate -u -r epoch
PowerShell[DateTimeOffset]::UtcNow.ToUnixTimeSeconds()[DateTimeOffset]::FromUnixTimeSeconds(epoch).UtcDateTime

JavaScript / TypeScript

// Current epoch (seconds — drop the floor for milliseconds)
Math.floor(Date.now() / 1000)

// Convert epoch (seconds) to Date
new Date(epoch * 1000)

// Format as ISO 8601 UTC
new Date(epoch * 1000).toISOString()

// Format in user's local timezone
new Date(epoch * 1000).toLocaleString()

// Convert ISO date string to epoch seconds
Math.floor(new Date('2026-01-01T00:00:00Z').getTime() / 1000)

Date.now() returns milliseconds. Divide by 1000 for seconds. The Math.floor matters when you need an integer to pass to a backend that expects seconds.

Databases

EngineGet current epoch (seconds)Convert epoch to timestamp
PostgreSQLEXTRACT(EPOCH FROM NOW())::BIGINTTO_TIMESTAMP(epoch)
MySQLUNIX_TIMESTAMP()FROM_UNIXTIME(epoch)
SQL ServerDATEDIFF_BIG(SECOND, '1970-01-01', SYSUTCDATETIME())DATEADD(SECOND, epoch, '1970-01-01')
SQLiteunixepoch()datetime(epoch, 'unixepoch')
Oracle(SYSDATE - DATE'1970-01-01') * 86400TIMESTAMP '1970-01-01 00:00:00 UTC' + NUMTODSINTERVAL(epoch, 'SECOND')
MongoDBMath.floor(Date.now() / 1000)new Date(epoch * 1000)

For SQL Server pre-2016, replace DATEDIFF_BIG with DATEDIFF (returns INT — overflows for very large differences).

Spreadsheets

ApplicationConvert epoch (seconds) in cell A1 to date
Excel / LibreOffice Calc=(A1 / 86400) + DATE(1970, 1, 1)
Google Sheets=A1/86400 + DATE(1970, 1, 1)

Format the result cell as Date/Time. Result is in UTC. For local time, add or subtract the timezone offset in seconds: =((A1 + 3600*(-5)) / 86400) + DATE(1970, 1, 1) for US Eastern Standard Time (UTC-5).

Common pitfalls and fixes

SymptomCauseFix
Date is off by ~50 yearsMixed seconds and milliseconds (treated 1.7B ms as 1.7B s)Divide ms by 1000, or use a 13-digit-aware parser
Date is off by exactly N hoursLocal time vs UTC mismatchUse UTC explicitly: Python datetime.fromtimestamp(e, tz=timezone.utc), JS toISOString(), etc.
Year shows 1900C tm_year field is years since 1900Add 1900 to tm_year before display
Year shows 1970 / Jan 1Null or zero epochValidate input is non-zero before conversion
Epoch shifts by a few seconds vs realityUTC vs TAI (leap seconds not counted)Most languages skip leap seconds; this is normally correct, not a bug
Dates after Jan 19, 2038 wrap negativeSigned 32-bit time_t overflow (Y2K38)Use 64-bit time_t (default on most modern systems) or store epoch in milliseconds
Date(1234567890) shows year 1970 in JSJS Date constructor expects milliseconds, not secondsMultiply by 1000: new Date(1234567890 * 1000)
time.time() returns a float in PythonPython returns sub-second precision by defaultWrap in int() if you need integer seconds

Date formatting reference

Most-used format strings across languages:

Formatstrftime / Python / Ruby / PHP / BashJavaScript Intl
ISO 8601 (2026-05-12T14:30:00Z)%Y-%m-%dT%H:%M:%SZ.toISOString()
RFC 2822 (Tue, 12 May 2026 14:30:00 GMT)%a, %d %b %Y %H:%M:%S GMT.toUTCString()
US short (05/12/2026)%m/%d/%Y.toLocaleDateString('en-US')
EU short (12/05/2026)%d/%m/%Y.toLocaleDateString('en-GB')
Long form (Tuesday, May 12, 2026)%A, %B %d, %Y.toLocaleDateString('en-US', { dateStyle: 'full' })

Related concepts

  • Year 2038 problem. Signed 32-bit Unix timestamps overflow on 2038-01-19 03:14:07 UTC. Most modern systems use 64-bit, but embedded systems and older databases may still be vulnerable.
  • POSIX time vs TAI. Unix time deliberately excludes leap seconds. TAI (International Atomic Time) counts every second since 1958-01-01 and is currently 37 seconds ahead of UTC.
  • ISO 8601. The international standard for date representation. Format YYYY-MM-DDTHH:MM:SS±HH:MM (or Z for UTC). Sortable as a string. Recommended over RFC 2822 for new systems.
  • Timezone names vs offsets. An offset like -05:00 is unambiguous at a moment but doesn't tell you the timezone (which DST rules apply). A name like America/New_York tracks the rules across history.
Read more on /learn