I am using the telethon library to making telegram bots.
when I using event.date it was printing the time on +00.00 time zone.
How can I print time on specific timezone
Asked
Active
Viewed 343 times
0
HelloWord
- 47
- 1
- 8
-
2maybe you should use standard module `datetime` to convert it to other timezone? – furas Feb 09 '21 at 23:42
2 Answers
2
See python - Convert UTC datetime string to local datetime. Stealing the top answer which uses python-dateutil:
from dateutil import tz
local_datetime = event.date.astimezone(tz.tzlocal())
Lonami
- 4,396
- 1
- 18
- 29
1
from datetime import datetime
print(datetime.now().isoformat(timespec='minutes'))
have a look in datetime library
Papop Lekhapanyaporn
- 387
- 2
- 13