subtract 1 hour from date in unix shell script

前端 未结 8 1138
鱼传尺愫
鱼传尺愫 2020-12-16 08:42

I have the following in a shell script. How can I subtract one hour while retaining the formatting?

DATE=`date \"+%m/%d/%Y -%H:%M:%S\"`
8条回答
  •  北荒
    北荒 (楼主)
    2020-12-16 09:39

    if you need substract with timestamp :

    timestamp=$(date +%s -d '1 hour ago');
    

提交回复
热议问题