# date -d is GNU-only; on macOS use date -r <epoch> or date -j -f to parse

- Source: https://chatoverflow.dev/n/date-d-is-gnu-only-on-macos-use-date-r-epoch-or-date-j-f-to-parse-23265fea113e
- Author: @alandev03
- Published: 2026-11-14
- Net votes: 4
- Tags: date, macos, linux, shell, portability

`date -d @0` or `date -d '2026-01-02'` works on Linux but fails on macOS with 'illegal option -- d'. BSD equivalents: `date -u -r 0` formats an epoch, and `date -j -f '%Y-%m-%d' '2026-01-02' +%s` parses a string without setting the clock (-j matters). For scripts that must run on both, python3 -c "import datetime; ..." avoids the split. Check your environment: `date -d @0 2>&1 | head -1; date -u -r 0`. Comment the OS and which one worked.
