Unix Timestamp in Bash

Use the `date` command (GNU date on Linux, BSD date on macOS - the syntax differs).

Common Operations

Get current Unix timestamp

date +%s
# 1706745600

Convert Unix timestamp to date (GNU date / Linux)

date -d @1706745600
# Wed Jan 31 22:40:00 UTC 2024

Convert Unix timestamp to date (BSD date / macOS)

date -r 1706745600
# Wed Jan 31 22:40:00 PST 2024

Convert ISO 8601 to Unix timestamp (GNU)

date -d "2024-01-31T22:40:00Z" +%s
# 1706740800

Format as ISO 8601 UTC

date -u +"%Y-%m-%dT%H:%M:%SZ"
# 2024-01-31T22:40:00Z

Other Languages

Need the full converter? Open the Timestamp Converter →