Shell中日期加减运算示例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| [zhaoty@ZHTY shell]$ s="2020/08/17 09:12:18"
[zhaoty@ZHTY shell]$ ss=`date +%s -d "$s"`
[zhaoty@ZHTY shell]$ rs="2347"
[zhaoty@ZHTY shell]$ es=$(($ss+$rs))
[zhaoty@ZHTY shell]$ et=$(date +%Y/%m/%d\ %H:%M:%S -d "1970/01/01 UTC $es seconds")
$ 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
|
蚂蚁🐜再小也是肉🥩!