For those of you on linux, mac with bash, or WSL with bash I assembled a simple script to calculate time between dates similar to timeanddate.com's days calculator.
function datediff() {
d1=$(date -d "$1" +%s)
d2=$(date -d "$2" +%s)
sec=$(($d1 - d2))
sec=${sec#-}
echo $sec seconds
echo $((sec / 60)) minutes
echo $((sec / 60 / 60)) hours
echo $((sec / 60 / 60 / 24)) days
echo $((sec / 60 / 60 / 24 / 7)) weeks, $(( (sec / 60 / 60 / 24) % 7)) days
}
drop that in your .bashrc or a separate .sh file with #!/bin/bash at the top.
Usage:
$ datediff '3 Nov 2020' '1 Feb 2021'
7,776,000 seconds
129,600 minutes
2160 hours
90 days
12 weeks and 6 days