Last active
August 15, 2019 17:28
-
-
Save rogersguedes/1775de65ee549ea9766ca873cafd6ffe to your computer and use it in GitHub Desktop.
calculates the time between current time and a given date time.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [[ -z $1 ]] | |
then | |
echo $0 " Usage:" | |
echo " ${0} <date>" | |
echo " Example: ${0} 1990-09-21" | |
exit | |
fi | |
past_secs=$(date --date ${1} +%s) | |
now_secs=$(date +%s) | |
diff=`echo ${past_secs}-${now_secs}|bc` | |
msecs=`echo ${diff}*1000|bc` | |
echo ${msecs} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment