How to check time from internet using bash or python? -


this question has answer here:

this should simple task, after 2 hours of searching , reading documents failed find way check date , time internet using bash or python without installing ntplib.

i looking equivalent of pythons now() or bash $ date, using ntp (or other way) correct date , time internet. methods find (such ntpd) meant correct system time, not purpose.

easy way correct time in python

import time import os  try:     import ntplib     client = ntplib.ntpclient()     response = client.request('pool.ntp.org')     os.system('date ' + time.strftime('%m%d%h%m%y.%s',time.localtime(response.tx_time))) except:     print('could not sync time server.')  print('done.') 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -