shell 日期格式 2022-03-15

Posted 闭关苦炼内功

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了shell 日期格式 2022-03-15相关的知识,希望对你有一定的参考价值。

  • 前一天

date -d '-1 day' +%F

[test@localhost ~]$ date1=`date -d '-1 day' +%F`
[test@localhost ~]$ echo $date1
2022-03-14
[test@localhost ~]$
  • 今天

date +%F

[test@localhost ~]$ date2=`date +%F`
[test@localhost ~]$ echo $date2
2022-03-15
[test@localhost ~]$
  • 后一天

date -d '+1 day' +%F

[test@localhost ~]$ date3=`date -d '+1 day' +%F`
[test@localhost ~]$ echo $date3
2022-03-16
[test@localhost ~]$

以上是关于shell 日期格式 2022-03-15的主要内容,如果未能解决你的问题,请参考以下文章