System and processes

The date command

Shows or sets the system date and time, and converts dates between formats. With + and a format it prints dates your way; with -d it computes relative dates or parses a text string.

Syntax

date [opciones] [+formato]Try it in the terminal →

Most useful options

+%FDate in ISO format: YYYY-MM-DD.
+%TTime in HH:MM:SS format.
-d <texto>Uses that date instead of the current one: yesterday, +3 days, next monday or 2026-01-01.
-uShows the time in UTC, useful in scripts that must not depend on the time zone.
-r <archivo>Shows the last modification date of a file.
-IDate and time in ISO 8601 format (-Iseconds adds the seconds).
-s <texto>Sets the system date and time. Only root can do it.

Copy-ready examples

$ dateCurrent date and time, with the machine's time zone.

Example output

Tue Nov  3 10:15:22 CET 2026
$ date +%FOnly the date in ISO format, handy for file names.

Example output

2026-11-03
$ date -d '+3 days' +%FThe date three days from now.

Example output

2026-11-06
$ date -u -d @1793700000 '+%F %T'Converts a Unix timestamp (seconds since 1970) to a UTC date.

Example output

2026-11-03 10:00:00
$ date -d '2026-11-03 10:02' '+%F %R'Parses a written date and prints it in another format.

Example output

2026-11-03 10:02

You can try them in the browser terminal: it does not touch your computer.

Common errors

MessageCauseFix
date: invalid date 'nope'The text is not read as a date: use known formats or English phrases such as yesterday.Try 2026-11-03 or +1 week.
date: invalid date '2026-13-45'The month or day does not exist: months run from 01 to 12 and the day depends on the month.Check the date; the YYYY-MM-DD format makes the mistake easier to spot.
date: nofile: No such file or directoryWith -r the date comes from the file, and that file does not exist.Check the file path with ls and run the command again.
date: cannot set date: Operation not permittedChanging the time requires root; a normal user gets this error with -s.Use sudo timedatectl set-ntp true to sync with NTP.

Typical mistakes

  • The -d formats are GNU date's: on macOS (BSD) the syntax is different.

Differences from similar commands

  • timedatectl: Manages the time zone and NTP synchronization in systemd. date only shows or sets the time once.
  • uptime: Shows how long the machine has been up and the load average. It does not handle dates.

Security

date -s changes the system clock and can break TLS certificates, cron and logs, which is why only root can do it. Syncing with NTP is the better option: sudo timedatectl set-ntp true.

Related commands

FAQ

How do I print yesterday's date in ISO format?

With date -d yesterday +%F. For last month, date -d '1 month ago' +%F.

How do I convert a Unix timestamp to a date?

With date -d @1793700000, which counts the seconds since 1 January 1970.

More System and processes commands

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course