Skip to content

Instantly share code, notes, and snippets.

@niun
Created July 15, 2016 17:19
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 niun/be6d97ad4b65f163ab0d0e9fb86a73af to your computer and use it in GitHub Desktop.
Save niun/be6d97ad4b65f163ab0d0e9fb86a73af to your computer and use it in GitHub Desktop.
show time from Internetz in shell, iso-8601
curl -G -s --data-urlencode "format=%FT%T%:z" http://www.timeapi.org/cet/now # www.timeapi.org cet is CET/CEST. Don't use cest
date --iso-8601='seconds' -d "$(curl -s http://www.timeapi.org/utc/now)" # www.timeapi.org use local timezone settings
date -d "$(curl -s http://www.timeapi.org/utc/now)" +"%FT%T (UTC%:z = %Z)" # not quite ISO with timezone illustration
date -d "$(curl -s http://www.timeapi.org/utc/now)" +"%A %d.%m.%Y, %T (UTC%:z = %Z)" # non-ISO, easy readable by a german with day of week
date --iso-8601='seconds' -d "$(curl -s --head http://google.com | grep ^Date: | sed 's/Date: //g')" # google.com
date --iso-8601='seconds' -d "$(cat </dev/tcp/time.nist.gov/13 | cut -d' ' -f2,3) UTC" # NIST
date --iso-8601='seconds' -d "$(cat </dev/tcp/de.pool.ntp.org/13)" # ntp pool project
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment