Converting a string to a formatted date-time string using Python

前端 未结 5 1267
予麋鹿
予麋鹿 2020-12-05 07:37

I\'m trying to convert a string \"20091229050936\" into \"05:09 29 December 2009 (UTC)\"

>>>import time
>>>s = time.strptime(\"200912290509         


        
5条回答
  •  情深已故
    2020-12-05 07:55

    You can use easy_date to make it easy:

    import date_converter
    my_datetime = date_converter.string_to_string("20091229050936", "%Y%m%d%H%M%S", "%H:%M %d %B %Y (UTC)")
    

提交回复
热议问题