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
I would convert the dates to UNIX timestamps; you can subtract to get the difference in seconds, then divide by 60:
#!/bin/bash MPHR=60 # Minutes per hour. CURRENT=$(date +%s -d '2007-09-01 17:30:24') TARGET=$(date +%s -d'2007-12-25 12:30:00') MINUTES=$(( ($TARGET - $CURRENT) / $MPHR ))