Back to the command reference

date

SystemBeginner In simulator In real Linux

Show or set the date and time

Name: date

You can practise it right away in the simulator, and use it in real Linux mode too.

Description

date prints the current date and time, or in a +FORMAT you choose: +%F gives 2026-01-15, +%s a Unix timestamp. GNU date's -d parses and computes times, e.g. date -d "3 days ago".

Setting the clock needs root; timedatectl is preferred on modern systems.

Syntax

date [OPTION]... [+FORMAT]

Common options

+%FFormat: YYYY-MM-DD
+%TFormat: HH:MM:SS
+%Y%m%d-%H%M%SDate and time run together, for file names: backup-$(date +%Y%m%d-%H%M%S).tar.gz
+%a %b %j %uWeekday (Mon), month name (Jan), day of the year, weekday number (1–7)
+%sSeconds since 1970 (Unix timestamp)
-d / --date STRINGShow a given time, e.g. -d tomorrow
-u / --utcUse UTC
-I / --iso-8601ISO 8601 (-Iseconds adds the time)
-R / --rfc-emailThe e-mail header format (Mon, 15 Jan 2026 09:30:00 +0000)
-r / --reference FILEShow FILE’s modification time
-s / --set STRINGSet the system time (needs root)

Examples

  • $ date

    Show the current date and time

    Explain
  • $ date +%F

    Date only

    Explain
  • $ date "+%Y年%m月%d日 %H:%M"

    Custom format

    Explain

Related