date
- display or set system time.
Syntax
1
| date [OPTIONS] [+FORMAT]
|
common FORMAT |
Description |
%Y |
year |
%y |
last two digits of year(00…99) |
%m |
month |
%d |
day of month(e.g. 01) |
%F |
full date; same as %Y-%m-%d |
%H |
hour(00…23) |
%l |
hour(01…12) |
%k |
hour(0…23) |
%M |
minute (00..59) |
%S |
second (00..60) |
%T |
time; same as %H:%M:%S |
Options
Option |
Description |
-d, --date=STRING |
display time described by STRING, not ‘now’ |
-u |
print or set Coordinated Universal Time |
Examples
1
| date -u +"%Y-%m-%dT%H:%M:%SZ"
|
sample output
1
| Mon 07 Jan 2019 09:21:51 PM EST
|
Display date and time
output
Display unix time
Unix time is seconds since Unix epoch
Display a future date
next month
1
| date -d next-month +%Y-%m
|
Nov 25 of the year
10 minutes later
1
| date -d '10 minutes' +%H:%M:%S
|
Reference