How to write a python program to convert time from 12 hour to 24 hour format

Spread the love

In this program, you will learn How to write a python program to convert time from 12 hour to 24 hour format .

Here first, we will import datetime functionĀ  from python library. then we will use datetime.strptime() function.

Program

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

Output:

2018-12-14 13:07:00

 

admin

Leave a Reply

Your email address will not be published. Required fields are marked *