subtract 1 hour from date in unix shell script

前端 未结 8 1091
鱼传尺愫
鱼传尺愫 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:40

    If you need change timezone before subtraction with new format too:

    $(TZ=US/Eastern date -d '1 hour ago' '+%Y-%m-%d %H:%M')
    

提交回复
热议问题