Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

date

Show the date and time in any format, calculate other dates, or set the system clock.

Niveau
RHCSA-examen
Groep
Tijd
Root nodig
Voor wijzigingen
Pakket
coreutils

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

Wat het doet

date prints the current time in your time zone. +FORMAT controls the output (%F = 2026-10-25), -d shows another moment ("tomorrow", "+3 days", "@EPOCH"), -u uses UTC. root can set the clock with -s, but on a system with NTP chrony will correct it — use timedatectl and chrony instead.

Zo schrijf je het

date [OPTION]... [+FORMAT]
date [-u] -s "DATE TIME"

Belangrijkste delen

%F
Date: 2026-10-25.
%T
Time: 11:42:10.
%Y %m %d
Year, month, day.
%H %M %S
Hour, minute, second.
%s
Seconds since 1970-01-01 UTC (epoch).
%a %A / %b %B
Short/long day name / month name.
%j
Day of the year.
%u
Day of the week (1 = Monday).
%V
ISO week number.
%z %Z
Time zone offset / name.
%N
Nanoseconds.

Opties 12

Meest gebruikt

-d, --date=STRING
Show this moment instead of now: "yesterday", "+2 hours", "next monday", "@1761389000".
-u, --utc, --universal
Use UTC.
-s, --set=STRING
Set the clock (root).
-I[FMT], --iso-8601[=FMT]
ISO 8601 output (date, hours, minutes, seconds, ns).
--rfc-3339=FMT
RFC 3339 output (date, seconds, ns).
-R, --rfc-email
RFC 5322 (mail) format.
-r, --reference=FILE
Show the change time of a file.
-f, --file=FILE
Like -d for each line of a file.
--debug
Show how the date string was understood.
--resolution
Show the time resolution.
--help
Show help.
--version
Show the version.

Voorbeelden 11

$ als gewone gebruiker# als root (of met sudo)

  1. 1Now

    date
    Sun Oct 25 11:42:10 +03 2026

    Local time zone.

  2. 2A file-name friendly stamp

    tar -czf /backup/etc-$(date +%F_%H%M).tgz /etc

    etc-2026-10-25_1142.tgz.

  3. 3UTC

    date -u

    Same moment in UTC (logs from many servers).

  4. 4Calculate dates

    date -d '+30 days' +%F
    date -d 'last friday' +%F

    Expiry dates for chage -E.

  5. 5Epoch seconds

    date +%s
    1761381730
    date -d @1761381730

    Convert log time stamps.

  6. 6ISO format

    date -Iseconds
    2026-10-25T11:42:10+03:00

    For JSON and APIs.

  7. 7Time of a file change

    date -r /etc/passwd

    When was a user changed?

  8. 8Time in another zone

    TZ=Europe/Amsterdam date

    Without changing the system.

  9. 9Set the clock (lab without NTP)

    timedatectl set-ntp false; date -s "2026-10-25 12:00:00"

    With NTP on, chrony corrects it.

  10. 10Days until a certificate expires (security)

    echo $(( ( $(date -d "$(openssl x509 -enddate -noout -in /etc/pki/tls/certs/site.crt | cut -d= -f2)" +%s) - $(date +%s) ) / 86400 ))

    Alert when it gets low.

  11. 11Measure how long something takes

    S=$(date +%s); sleep 2; echo "took $(( $(date +%s) - S )) s"

    Simple timing in scripts.

Exitcodes

0 :: Done. 1 :: Error.