Skip to content

Instantly share code, notes, and snippets.

@rogersguedes
Last active August 15, 2019 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rogersguedes/1775de65ee549ea9766ca873cafd6ffe to your computer and use it in GitHub Desktop.
Save rogersguedes/1775de65ee549ea9766ca873cafd6ffe to your computer and use it in GitHub Desktop.
calculates the time between current time and a given date time.
#!/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