How to extract hours and minutes from a datetime.datetime object?

前端 未结 4 1396
渐次进展
渐次进展 2020-12-15 02:25

I am required to extract the time of the day from the datetime.datetime object returned by the created_at attribute. But I do not understand how to do that. This is my code

4条回答
  •  囚心锁ツ
    2020-12-15 03:14

    It's easier to use the timestamp for this things since Tweepy gets both

    import datetime
    print(datetime.datetime.fromtimestamp(int(t1)).strftime('%H:%M'))
    

提交回复
热议问题