$linuxjunkies
>

date(1)

Display or set the system date and time.

UbuntuDebianFedoraArch

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

FlagWhat it does
-u, --utcDisplay or set time in UTC (Coordinated Universal Time) instead of local time
-d, --date STRINGDisplay date/time described by STRING (e.g., '2 days ago', 'next Monday') rather than now
-f, --file DATEFILERead 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-emailOutput in RFC 5322 format suitable for email headers
-s, --set STRINGSet system time to STRING (requires root); same format as -d option
+FORMATUse 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)

date

Show 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 -I

Set system time to March 23, 2024 at 2:30 PM (requires root)

sudo date -s '2024-03-23 14:30:00'

Related commands