Skip to content

Instantly share code, notes, and snippets.

@pawiromitchel
Created November 26, 2020 21:57
Show Gist options
  • Save pawiromitchel/e74c66351c5584532830787798758314 to your computer and use it in GitHub Desktop.
Save pawiromitchel/e74c66351c5584532830787798758314 to your computer and use it in GitHub Desktop.
Calculate datetime difference between 2 dates in #bash
Value1=$(TZ=Europe/Amsterdam date "+%F %H:%M:%S")
Value2=$(TZ=America/Paramaribo date "+%F %H:%M:%S")
Difference=$(($(date -d "$Value1" '+%s') - $(date -d "$Value2" '+%s')))
expr $Difference / 3600
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment