Bash script: difference in minutes between two times

前端 未结 7 1633
不思量自难忘°
不思量自难忘° 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:15

    STARTTIME=$(date +%s)
    

    YOUR CODES :

    ENDTIME=$(date +%s)
    secs=$(($ENDTIME - $STARTTIME))
    printf 'Elapsed Time %dh:%dm:%ds\n' $(($secs/3600)) $(($secs%3600/60)) $(($secs%60)) 
    

提交回复
热议问题