Skip to content

Instantly share code, notes, and snippets.

@raresteak
Created February 4, 2021 15:16
Show Gist options
  • Save raresteak/5ade4a77cc52561fc1c57dee7ae0d8b5 to your computer and use it in GitHub Desktop.
Save raresteak/5ade4a77cc52561fc1c57dee7ae0d8b5 to your computer and use it in GitHub Desktop.
Show remaining seconds, minutes, days, years to 32bit clock roll over on 19 January 2038 03:14:18 UTC
#!/bin/bash
NOW=$(date -u -d "now" +%s)
EOW=$(date -u -d "19 January 2038 03:14:08 UTC" +%s )
echo "Remaining time from Now: $(date -u) to "
echo " $(date -u -d "19 January 2038 03:14:18 UTC")"
echo "Remaining seconds: $(expr $EOW - $NOW)"
echo "Remaining minutes: $(echo "scale=2;$(expr $EOW - $NOW)/60" | bc)"
echo "Remaining hours : $(echo "scale=2;($(expr $EOW - $NOW)/60)/60" | bc)"
echo "Remaining days : $(echo "scale=2;(($(expr $EOW - $NOW)/60)/60)/24" | bc)"
echo "Remaining years : $(echo "scale=2;((($(expr $EOW - $NOW)/60)/60)/24)/365" | bc)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment