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
Niets past bij dit filter.
Voorbeelden 11
$ als gewone gebruiker# als root (of met sudo)
1Now
date Sun Oct 25 11:42:10 +03 2026Local time zone.
2A file-name friendly stamp
tar -czf /backup/etc-$(date +%F_%H%M).tgz /etcetc-2026-10-25_1142.tgz.
3UTC
date -uSame moment in UTC (logs from many servers).
4Calculate dates
date -d '+30 days' +%F date -d 'last friday' +%FExpiry dates for chage -E.
5Epoch seconds
date +%s 1761381730 date -d @1761381730Convert log time stamps.
6ISO format
date -Iseconds 2026-10-25T11:42:10+03:00For JSON and APIs.
7Time of a file change
date -r /etc/passwdWhen was a user changed?
8Time in another zone
TZ=Europe/Amsterdam dateWithout changing the system.
9Set the clock (lab without NTP)
timedatectl set-ntp false; date -s "2026-10-25 12:00:00"With NTP on, chrony corrects it.
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.
11Measure how long something takes
Simple timing in scripts.
Niets past bij dit filter.
Exitcodes
0 :: Done. 1 :: Error.