Name
date
Synopsis
date [options
] [+
format
] [date
]
Print the current date and time. You may specify a display format, which can consist of literal text strings (blanks must be quoted) as well as field descriptors, whose values are described in the following entries (the listing shows some logical groupings). A privileged user can change the system’s date and time.
Options
- +format
Display current date in a nonstandard format. For example:
$
date +"%A %j %n%k %p"
Friday 051 23 PMThe default is %a %b %e %T %Z %Y (e.g., Fri Feb 20 22:59:43 EST 2009).
- -d date, --date date
Display date, which should be in quotes and may be in the format d days or m months d days, to print a date in the future. Specify ago to print a date in the past. You may include formatting (see the following section).
- -f datefile, --file=datefile
Like -d, but printed once for each line of datefile.
- -r file, --reference=file
Display the time file was last modified.
- -R, --rfc-2822
Display the date and time in RFC 2822 format.
- --rfc-3339=timespec
Display the date and time in RFC 3339 format. The value of timespec can be one of date, seconds, or ns (nanoseconds) to get the desired degree of precision.
- --help
Print help message and exit.
- --version
Print version information and exit.
- -s date, --set=date
Set the date.
- -u, --utc, --universal
Set the date to Coordinated Universal Time, not local time.
Format
The exact result of many of these codes is locale-specific and depends upon your language setting, particularly the LANG environment variable. ...
Get Linux in a Nutshell, 6th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.