Last active
May 1, 2023 17:07
-
-
Save thesuhu/1293dd2c3654d49200b3ae2464c5a2f5 to your computer and use it in GitHub Desktop.
Get UTC Time From Internet
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 | |
# get UTC date | |
date -u -d "$(curl -sI google.com | grep -i '^date:' | cut -d' ' -f2-)" | |
# get local date from UTC | |
date -d "$(curl -sI google.com| grep -i '^date:'|cut -d' ' -f2-)" | |
# sync local date from UTC | |
sudo date -s "$(date -d "$(curl -sI google.com | grep -i '^date:' | cut -d' ' -f2-)" '+%Y-%m-%d %H:%M:%S')" | |
# UTC vs local | |
date -d "$(curl -sI google.com| grep -i '^date:'|cut -d' ' -f2-)" && date | |
date -u -d "$(curl -sI google.com| grep -i '^date:'|cut -d' ' -f2-)" && date -u |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment