Reputation: 4927
I am using python v3.6 to get current time.
import time
current_time = time.strftime("%H:%M:%S %Y-%m-%d", time.gmtime())
The code works but the time retrieved is from some other time zones. How do I retrieve time that is the same as reflected on the Windows 10 clock on my PC?
Upvotes: 0
Views: 72
Reputation: 105
Try the below. I expect gmtime is for GMT(UTC more likely), vs local. See https://docs.python.org/2/library/time.html
>>> time.strftime("%H:%M:%S %Y-%m-%d", time.gmtime())
'03:16:00 2017-08-20'
>>> time.strftime("%H:%M:%S %Y-%m-%d", time.localtime())
'13:16:08 2017-08-20
Upvotes: 1