import socket, sys, struct, timehostname = 'time.nist.gov'port = 37host = socket.gethostbyname(hostname)s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)s.sendto('', (host, port))print "Looking for replies; press Ctrl-C to stop."buf = s.recvfrom(2048)[0]if len(buf) != 4: print "Wrong-sized reply %d: %s" % (len(buf), buf) sys.exit(1)secs = struct.unpack("!I", buf)[0]secs -= 2208988800print time.ctime(int(secs))
Name (required)
email (will not be published) (required)
Website