Current Unix Timestamp
Seconds
0
Milliseconds
0
Convert
UTC
—
Local
—
ISO
—
:
Seconds
—
Milliseconds
—
Hex
—
Get current Unix time in code
C# / .NET
// seconds
DateTimeOffset.UtcNow.ToUnixTimeSeconds()
// milliseconds
DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()
// from timestamp
DateTimeOffset.FromUnixTimeSeconds(ts)
JavaScript / TypeScript
// seconds
Math.floor(Date.now() / 1000)
// milliseconds
Date.now()
// from timestamp
new Date(ts * 1000).toISOString()
Python
# seconds
import time; int(time.time())
# from timestamp
datetime.fromtimestamp(ts, tz=timezone.utc)
Go
// seconds
time.Now().Unix()
// from timestamp
time.Unix(ts, 0).UTC()
SQL (PostgreSQL / MySQL)
-- current
SELECT EXTRACT(EPOCH FROM NOW());
-- from timestamp
SELECT TO_TIMESTAMP(1716000000);
Shell / PowerShell
# bash
date +%s
# PowerShell
[DateTimeOffset]::UtcNow.ToUnixTimeSeconds()
Common durations in seconds
| Duration | Seconds | Use case |
|---|---|---|
| 1 minute | 60 | Short cache TTL |
| 1 hour | 3 600 | Session timeout |
| 1 day | 86 400 | Daily job, cookie expiry |
| 1 week | 604 800 | JWT refresh token |
| 30 days | 2 592 000 | Monthly subscription |
| 1 year (365d) | 31 536 000 | Long-lived token, cert |
| 10 years | 315 360 000 | Root CA certificate |
| Unix max (32-bit) | 2 147 483 647 | Year 2038 problem — Jan 19, 2038 |