Name
date — stdin stdout - file -- opt --help --version
Synopsis
date [options
] [format
]
The date
command prints
dates and times. The results will depend on your system’s locale
settings (for your country and language). In this section we assume
an English, US-based locale.
By default, date
prints the
system date and time in the local timezone:
$ date Sun Sep 28 21:01:31 EDT 2003
You can format the output differently by supplying a format string beginning with a plus sign:
$ date '+%D' 09/28/03 $ date '+The time is %l:%M %p on a beautiful %A in %B' The time is 9:01 PM on a beautiful Sunday in September
Here is a sampling of the date
command’s many formats:
Format |
Meaning |
Example (US English) |
---|---|---|
Whole dates and times: | ||
|
Full date and time, 12-hour clock |
Sun 28 Sep 2003, 09:01:25 PM EDT |
|
Numeric date, 2-digit year |
09/28/03 |
|
Numeric date, 4-digit year |
09/28/2003 |
|
Time, 24-hour clock |
21:01:25 |
|
Time, 12-hour clock |
09:01:25 PM |
Words: | ||
|
Day of week (abbreviated) |
Sun |
|
Day of week (complete) |
Sunday |
|
Month name (abbreviated) |
Sep |
|
Month name (complete) |
September |
|
Time zone |
EDT |
|
AM or PM |
PM |
Numbers: | ||
|
Day of week (0–6, 0=Sunday) |
0 |
|
Day of week (1–7, 1=Monday) |
7 |
|
Day of month, leading zero |
02 |
|
Day of month, leading blank |
2 |
|
Day of year, leading zeroes |
005 |
|
Month number, leading zero |
09 |
|
Year, 2 digits |
03 |
|
Year, 4 digits |
2003 |
|
Minute, leading zero |
09 |
Get Linux Pocket Guide, 2nd 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.