Python - datetime of a specific timezone

前端 未结 2 764
自闭症患者
自闭症患者 2021-02-05 21:42

I am having the hardest time trying to get the current time in EDT timezone.

print datetime.time(datetime.now()).strftime(\"%H%M%S\")

datetime.

2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-05 22:07

    The tzinfo class only defines an interface, you will need to implement it yourself (see the documentation for an example) or use a third-party module which implements it, like pytz.

    Edit: Sorry, I missed that you don't want to import another library.

提交回复
热议问题