For Developers

Unix Timestamp in Bash

How to get the current timestamp, convert it to a date, and convert a date back to a timestamp in Bash — plus the specific mistake that trips up Bash code more than any other.

date +%s
date -d @1750000000
date -d "2025-06-15 12:00:00 UTC" +%s

The Bash-specific pitfall

The date command's flags differ between GNU (Linux) and BSD (macOS) — the -d @TIMESTAMP syntax above is GNU-only; macOS's built-in date needs -r TIMESTAMP instead. Scripts written and tested on Linux frequently break silently on a teammate's Mac for exactly this reason.

Have a timestamp right now?

Paste it into the Timestamp ⇄ Date Converter to check it instantly, in any timezone, without writing any code. Working across several languages on the same project? The full Epoch Time in Programming Languages guide has all of them side by side for quick comparison.

Related

Related tools & reading