skip to Main Content

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

2

Answers


  1. 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())
    
    Login or Signup to reply.
  2. from datetime import datetime
    print(datetime.now().isoformat(timespec='minutes'))
    

    have a look in datetime library

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search