date(1)
Display or set the system date and time.
Synopsis
date [OPTION]... [+FORMAT] or date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]Description
The date command displays the current date and time, or sets the system clock. Without arguments, it shows the date in the default locale format. You can customize the output with format strings or set a new date/time if you have sufficient privileges.
Format strings use % specifiers (e.g., %Y for year, %m for month, %d for day). See the examples for common patterns.
Common options
| Flag | What it does |
|---|---|
-u, --utc | Display or set time in UTC (Coordinated Universal Time) instead of local time |
-d, --date STRING | Display date/time described by STRING (e.g., '2 days ago', 'next Monday') rather than now |
-f, --file DATEFILE | Read dates from DATEFILE and display each one (one date per line) |
-I[TIMESPEC], --iso-8601[=TIMESPEC] | Output in ISO 8601 format; TIMESPEC is 'date', 'hours', 'minutes', or 'seconds' |
-R, --rfc-email | Output in RFC 5322 format suitable for email headers |
-s, --set STRING | Set system time to STRING (requires root); same format as -d option |
+FORMAT | Use custom format string with % specifiers; + is literal prefix |
Examples
Display current date and time in default format (Thu Mar 23 12:34:56 UTC 2024)
dateShow date in YYYY-MM-DD format (2024-03-23)
date '+%Y-%m-%d'Pretty format: Thursday, March 23, 2024 at 12:34 PM
date '+%A, %B %d, %Y at %I:%M %p'Display current UTC time in ISO-like format
date -u '+%Y-%m-%d %H:%M:%S'Show the date from 5 days ago
date -d '5 days ago' '+%Y-%m-%d'Display the date of the next Friday
date -d 'next Friday' '+%A %Y-%m-%d'Show date in ISO 8601 format (2024-03-23)
date -ISet system time to March 23, 2024 at 2:30 PM (requires root)
sudo date -s '2024-03-23 14:30:00'