format date 'Fri Apr 15 04_01_33 2016' and '2015-12-16 22-39-28' Using python datetime format date
Question: Here is Simples way to format date using datetime

    
    
    from datetime import datetime
    date = '2016-04-07 04-54-53'
    date1 = 'Fri Apr 15 04_01_33 2016'
    format = "%Y-%m-%d %H-%M-%S"
    format1 = "%a %b %d %H_%M_%S %Y"
    datetime = datetime.strptime(date, format)
    datetime1 = datetime.strptime(date1, format1)
    print(datetime)
    print(datetime1)
    

Output :

    
    
    2016-04-07 04:54:53
    2016-04-15 04:01:33
    


Answer: **Simples way to format date using datetime**

    
    
    from datetime import datetime
    date = '2016-04-07 04-54-53'
    date1 = 'Fri Apr 15 04_01_33 2016'
    format = "%Y-%m-%d %H-%M-%S"
    format1 = "%a %b %d %H_%M_%S %Y"
    datetime = datetime.strptime(date, format)
    datetime1 = datetime.strptime(date1, format1)
    print(datetime)
    print(datetime1)
    

Output :

    
    
    2016-04-07 04:54:53
    2016-04-15 04:01:33
    

Vote if you get right ans

