Convert 12 hour into 24 hour times

后端 未结 12 726
走了就别回头了
走了就别回头了 2020-12-31 08:17

I\'m trying to convert times from 12 hour times into 24 hour times...

Automatic Example times:

06:35  ## Morning
11:35  ## Morning (If m2 is anywhe         


        
12条回答
  •  难免孤独
    2020-12-31 08:18

    Instead of using "H" for hour indication use "I" as described in the example bellow:

    from datetime import *
    m2 = 'Dec 14 2018 1:07PM'
    m2 = datetime.strptime(m2, '%b %d %Y %I:%M%p')
    print(m2)
    

    Please check this link

提交回复
热议问题