Going from twitter date to Python datetime date

前端 未结 10 1304
谎友^
谎友^ 2020-12-23 09:21

I am receiving twitter messages that are sent at a certain date in the following format from twitter:

Tue Mar 29 08:11:25 +0000 2011

I want

10条回答
  •  心在旅途
    2020-12-23 10:17

    you can convert the date using datetime.strptime(), or time.strptime(). however, those two functions cannot parse the timezone offset (see this bug).

    so, the only solution i see is to split the date yourself, remove the timezone offset, feed the rest to strptime(), and process the offset manually...

    have a look at this question, where you will find some hints on how to parse the offset yourself.

提交回复
热议问题