Formats
Specifiers: %Y/%m/%d year/month/day, %H:%M:%S time, %s epoch,
%F/%T date/time, %j day of year, %A/%B weekday/month spelled out,
%z offset.
The date command: current time, output formats, timestamps for files and logs, date arithmetic.
date +%F
2026-06-30 (=%Y-%m-%d)
date +%Y%m%d-%H%M%S
a timestamp for filenames
date +%s
epoch: seconds since 1970
date -d @1700000000
epoch → human-readable
date -d "yesterday" +%F
yesterday
date -d "now + 1 hour" +%T
an hour from now
TZ='UTC' date
current time in another timezone
date -Iseconds
ISO 8601
tar czf "bk-$(date +%F).tgz" /etc
a date in a backup's name
date prints and formats the date/time. In scripts (bash-scripting), it's
used for timestamps in backup and log filenames. (System time and timezone
are configured with timedatectl.)
Below are the main flags of date; the full list is in man date (the +%…
format specifiers are a separate topic, see the table under "Recipes").
| Option | What it does | Example |
|---|---|---|
-u --utc |
Show the time in UTC instead of the local timezone. | date -u |
-d --date string |
Show a date parsed from a string (a timestamp, "yesterday", "now + 1 hour"), not the current one. | date -d "yesterday" +%F |
-I --iso-8601 date|hours|minutes|seconds |
Print the date/time in ISO 8601 format. | date -Iseconds |
-R --rfc-email |
Print the date in RFC 5322 format (for mail and HTTP headers). | date -R |
-s --set string |
Set the system clock manually; use timedatectl for regular synchronization. dangerous | sudo date -s "2026-06-30 14:00:00" |
-f --file datefile |
Read and print one date per line from a file. | date -f dates.txt |
Nothing found. Try a shorter query.
Specifiers: %Y/%m/%d year/month/day, %H:%M:%S time, %s epoch,
%F/%T date/time, %j day of year, %A/%B weekday/month spelled out,
%z offset.
date prints with spaces/: by default (bad for filenames). Use a format:
date +%Y%m%d-%H%M%S or %F.
date uses the system timezone. Check/change it via timedatectl; for UTC,
use date -u; for another zone once, TZ='Europe/London' date. A drifting
clock — NTP is covered in timedatectl.
It depends on the locale (LC_TIME). Set the locale you need (see locale):
LC_TIME=ru_RU.UTF-8 date '+%A %d %B'.
printf '%s %s\n' "$(date -Iseconds)" "message", or use the systemd
journal (journalctl adds timestamps itself).
Found an inaccuracy? Report an error in the article