AAA AAA - 26 days ago 9
Bash Question

how to calculate the total minutes between two dates?

Can anyone help me to calculate the total minutes between below two dates.

date1= 2016-07-02 06:20:00

date2= 2016-07-04 15:00:00

the output should be in number for example the date diff is only 5 hours means i need the output like 5*60=300 minutes.

Thanks,
AAA

Answer

echo $((($(date -ud "$date2" +'%s') - $(date -ud "$date1" +'%s'))/60)) minutes

Comments