• Home
  • LinuxBash
  • Get the time difference between two times, in hours, minutes and seconds

Get the time difference between two times, in hours, minutes and seconds

This one’s a no brainer.

date2=$(date +"%s")
#Wait for some time
date2=$(date +"%s")
diff=$(($date2-$date1))
echo "Time difference is $(($diff / 3600)) hours $(($diff / 60)) mins $(($diff % 60)) secs."