subtract 1 hour from date in unix shell script

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

    Convert to timestamp (a long integer), subtract the right number of milliseconds, reformat to the format you need.

    Hard to give more details since you don't specify a programming language...

提交回复
热议问题