Name
date [options
] [format
] — coreutils
Synopsis
/bin
stdin stdout - file -- opt --help --version
The date
command prints dates and times. By default, it 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
Format | Meaning | Example |
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 |
| Seconds, leading zero | 05 |
| Hour, 12-hour clock, leading blank | 9 |
| Hour, 12-hour clock, leading zero | 09 |
| Hour, 24-hour clock, leading blank | 9 |
| Hour, 24-hour clock, leading zero | 09 |
| Nanoseconds | 737418000 |
| Seconds since the beginning of Linux time: midnight January 1, 1970 | 1068583983 |
Other: | ||
| Newline | |
| Tab | |
| Percent sign | % |
Through its options, date
can also display other dates and times.
Useful options ... |
Get Linux Pocket Guide 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.