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 minute60Short cache TTL
1 hour3 600Session timeout
1 day86 400Daily job, cookie expiry
1 week604 800JWT refresh token
30 days2 592 000Monthly subscription
1 year (365d)31 536 000Long-lived token, cert
10 years315 360 000Root CA certificate
Unix max (32-bit)2 147 483 647Year 2038 problem — Jan 19, 2038