Skip to content

date command

Print or set the date and time, in any format.

On this page

Syntax

date [options] [+FORMAT]

Provided by the coreutils package. Run man date for the full manual.

Common options

OptionWhat it does
+FORMATOutput format, e.g. +%Y-%m-%d
-d STRINGShow a date other than now, e.g. "next monday"
-uUTC
-s STRINGSet the system date (root)
-r FILELast modification time of FILE
-IISO 8601 format

Examples

  1. Current date and time

    date
  2. Year-month-day

    date +%F
  3. Timestamp for file names

    date +%Y%m%d-%H%M%S
  4. Unix epoch seconds

    date +%s
  5. Convert an epoch to a date

    date -d @1767225600
  6. Tomorrow

    date -d tomorrow +%F
  7. 30 days ago

    date -d "30 days ago" +%F
  8. UTC in ISO 8601

    date -u -Iseconds
  9. Use in a backup name

    tar -czf "backup-$(date +%F).tar.gz" /etc

date guides

← All Linux commands · Suggest a fix

Back to top