Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os, ntplib
- from time import ctime
- from time import strptime
- def online_date():
- global day
- global month
- global year
- ntp_client = ntplib.NTPClient()
- res = ntp_client.request('pool.ntp.org')
- result = ctime(res.tx_time)
- m = result.split()
- month_word = m[1]
- year = m[4]
- day = m[2]
- month_num = strptime(month_word, '%b').tm_mon
- month = str(month_num)
- online_date()
- command = month + '-' + day + '-' + year
- print('current date (mm-dd-yyyy): ' + command)
- os.system('date ' + command)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement