分类:
2010-05-30 14:44:19
First, print today's date:$ date
Sun Jun 17 12:17:24 CDT 2007
Now display Yesterday's date:$ date --date="1 days ago"
OR try:$ date --date="yesterday"
Sat Jun 16 12:17:20 CDT 2007
Now display Tomorrow's date:$ date --date="-1 days ago"
Or better try:$ date --date="next day"
Sat Jun 16 12:17:20 CDT 2007
To get tomorrow and day after tomorrow (tomorrow+N) use day word to get date in the future.
To get yesterday and earlier day in the past use string day ago:
You can add year and months keywords to get more accurate date:$ date --date='2 year ago' # past
$ date --date='3 years' # go into future
$ date --date='2 days' # future
$ date --date='1 month ago' # past
$ date --date='2 months' # future
To print the date of this Friday:$ date --date='this Friday'
To print the date of the day six months and 15 day$ date --date='6 months 15 day'
To print the date of the day two months and 5 days ago:$ date --date='2 months 5 day ago'
You can also use relative format to setup date and time. For example to set the system clock forward by 30 minutes, enter:# date --set='+30 minutes'
To display date in :$ date --date='1970-01-01 00:00:01 UTC +5 hours' +%s