Bash script/command to print out date 5 min before/after

后端 未结 4 812
刺人心
刺人心 2021-01-01 16:03

I need to somehow use the date command in bash or another utility to print out the date and time, 5 minutes before and 5 minutes after a given value. For example:

i

4条回答
  •  伪装坚强ぢ
    2021-01-01 16:54

    You can achieve this, for the current time, by typing.

    $ date --date='5 minutes ago'; date; date --date='5 minutes'
    Qui Dez 19 16:09:17 BRST 2013
    Qui Dez 19 16:14:17 BRST 2013
    Qui Dez 19 16:19:17 BRST 2013
    

    To use a specific date (ex 1978/01/10).

    $ date --date='1978-01-10 + 5 minutes'
    Ter Jan 10 00:05:00 BRT 1978
    

提交回复
热议问题