shell 日期加减

shell 日期加减运算

 
比如今日是2012-04-22
$ date -d "+1 day" +%Y-%m-%d
2012-04-23
 
$ date -d "-1 day" +%Y-%m-%d
2012-04-21
 
$ date -d "2012-04-10 -1 day " +%Y-%m-%d
2012-04-09
 
$ date -d "2012-04-10 +1 day " +%Y-%m-%d
2012-04-11
 
$ date -d "-1 week " +%Y-%m-%d
2012-04-15
 
$ date -d "+1 week " +%Y-%m-%d
2012-04-29
 
$ date -d "+1 month " +%Y-%m-%d
2012-05-22
 
$ date -d "-1 month " +%Y-%m-%d
2012-03-22
 
$ date -d "-1 year " +%Y-%m-%d
2011-04-22
 
$ date -d "+1 year " +%Y-%m-%d
2013-04-22
posted @ 2016-10-26 11:41  howhy  阅读(16328)  评论(0编辑  收藏  举报