I am using software that uses python to connect to Twitter API.
Twitter API won’t connect if the time set on my PC is wrong.’
The problem is that Windows 10 time does not affect what python is reading. I can change windows time and timezone but python always shows me the wrong time.
I double-checked the BIOS time and its correct, and also I followed this instructions
https://windowsreport.com/wrong-time-on-windows-clock-fix/
But python still giving me the wrong time.
If I input this
from datetime import datetime
import pytz
local = datetime.now()
print("Local:", local.strftime("%m/%d/%Y, %H:%M:%S"))
Always is giving me one hour less than the bios time.
How can I fix this issue?
2
Answers
This should fix your problem:
https://stackoverflow.com/a/52114630/12130308
Or try:
This is likely a timezone issue. What is your local timezone? Do you know if it had some recent changes?
For example, several years ago Europe/Moscow timezone was switched between GMT+3 and GMT+4 – first the government decided to disable DST (daylight saving time) and fixed timezone to GMT+4, then they changed their mind and fixed timezone to GMT+3. All these changes resulted in timezone being inconsistent on some devices with older firmware.
So, if your timezone had some changes recently, then you may need to update timezone information either in Python or in Windows.
Another possible reason is that Linux/MacOS store UTC time in BIOS by default, and Windows stores local time in BIOS. This results in a mess when using several OSes on the same computer. Although I don’t think it could influence just Python in Windows without affecting Windows itself.
You can try this:
What will be the difference between the two resulting structures? Is it consistent with your local timezone?