date command
Print or set the date and time, in any format.
- Shell & scheduling
- Package coreutils
- 6 options · 9 examples
Syntax
date [options] [+FORMAT]Provided by the coreutils package. Run man date for the full manual.
Common options
| Option | What it does |
|---|---|
+FORMAT | Output format, e.g. +%Y-%m-%d |
-d STRING | Show a date other than now, e.g. "next monday" |
-u | UTC |
-s STRING | Set the system date (root) |
-r FILE | Last modification time of FILE |
-I | ISO 8601 format |
Examples
Current date and time
dateYear-month-day
date +%FTimestamp for file names
date +%Y%m%d-%H%M%SUnix epoch seconds
date +%sConvert an epoch to a date
date -d @1767225600Tomorrow
date -d tomorrow +%F30 days ago
date -d "30 days ago" +%FUTC in ISO 8601
date -u -IsecondsUse in a backup name
tar -czf "backup-$(date +%F).tar.gz" /etc
No example matches. Check the options table or search the guides.
date guides
- Your Ultimate Guide to the Linux Date Command Linux Commands · Updated Apr 2025
- How to Get Current Date and Time in Bash Script Shell Scripting · Updated Apr 2025
- Bash: Display Date and Time In a Specific Format Shell Scripting · Updated Apr 2025
