Difference between revisions of "date command"
From thelinuxwiki
(Created page with "to get a formatted date command, just append a + followed by format denotations just give me the year! # '''date +%Y''' year, month, day... # '''date +%Y-%m-%d''' ...") |
|||
(4 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
− | to get a formatted date command, just append a + followed by format denotations | + | to get a formatted date command, just append a + followed by format denotations. Just type in what characters you want to divide the parameters by. Dash, dot, ect... |
just give me the year! | just give me the year! | ||
# '''date +%Y''' | # '''date +%Y''' | ||
+ | 2013 | ||
year, month, day... | year, month, day... | ||
Line 9: | Line 10: | ||
just give me the time! | just give me the time! | ||
− | # date +%H.%M.%S ~ | + | # '''date +%H.%M.%S''' ~ |
23.00.20 | 23.00.20 | ||
+ | |||
+ | ==epoch conversion== | ||
+ | |||
+ | current date in epoch | ||
+ | $ date +%s | ||
+ | 1505537832 | ||
+ | |||
+ | date string to epoch | ||
+ | $ date -d '15Sep2017' +%s | ||
+ | 1505451600 | ||
+ | |||
+ | epoch to human readable date | ||
+ | $ date -d @1505537832 +%Y-%m-%d | ||
+ | 2017-09-15 |
Latest revision as of 15:56, 18 September 2017
to get a formatted date command, just append a + followed by format denotations. Just type in what characters you want to divide the parameters by. Dash, dot, ect...
just give me the year!
# date +%Y 2013
year, month, day...
# date +%Y-%m-%d ~ 2013-08-01
just give me the time!
# date +%H.%M.%S ~ 23.00.20
epoch conversion
current date in epoch
$ date +%s 1505537832
date string to epoch
$ date -d '15Sep2017' +%s 1505451600
epoch to human readable date
$ date -d @1505537832 +%Y-%m-%d 2017-09-15