Bash script: difference in minutes between two times

前端 未结 7 1634
不思量自难忘°
不思量自难忘° 2020-12-31 07:55

I have two time strings; eg. \"09:11\" and \"17:22\" on the same day (format is hh:mm). How do I calculate the time difference in minutes between these two?

Can the

7条回答
  •  佛祖请我去吃肉
    2020-12-31 08:20

    MPHR=60
    CURRENT=09:11
    TARGET=17:22
    echo $(( ( 10#${TARGET:0:2} - 10#${CURRENT:0:2} ) * MPHR + 10#${TARGET:4} - 10#${CURRENT:4} ))
    

提交回复
热议问题