command record-----date

date command --> used to display or set the date and time of the system; formatted output

 

Display time

date # display year, month, day, week, CST      

date '+%c' # display year, month, day, hour, minute and second

date -I # Display year-month-day 2017-02-17

date '+%D' # show the full time

date '+%x' # Display numeric date, year with two digits representing May 12, 2010

date '+%T' # display the date, the year is represented by four digits 14:09:31

date '+%X' # display 24 hour format 14:09:39

date '+%T%n%D' # Skip the line after displaying the time, and then display the current date

date '+%B %d' # display month and day

date -u # Display date and time in UTC

date -d 'dec 30 -2 weeks' # show the time two weeks ago compared to December 30

 

 

 

 

 

Add and subtract operations

date +%Y%m%d # Display the year, month and day of the previous day 

date -d "+1 day" +%Y%m%d # Display the date of the previous day 

date -d "-1 day" +%Y%m%d # Display the date of the next day 

date -d "-1 month" +%Y%m%d # Display the date of the previous month 

date -d "+1 month" +%Y%m%d # Display the date of the next month 

date -d "-1 year" +%Y%m%d # Display the date of the previous year 

date -d "+1 year" +%Y%m%d # display the date of the next year

date -d '30 days ago' # Display the time 30 days ago

date -d next-month +%Y%m # Display the next month time

 

12 hours later 2 minutes ago

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324539301&siteId=291194637