Datetime format problems
Question: I'm having problems converting a dateTime from one format to another.

    
    
    Mon 13 Jun 2016 10:00
    

should become

    
    
    13/06/2016 10:00:00
    

However, I'm having problems with the hours minutes & seconds (Yes I realise
the seconds are not supplied - so that might be causing formatting problems)

Here's what I've got so far:

    
    
    #!/usr/bin/env python  
    import datetime
    
    def convertDateString(s): 
      d = datetime.datetime.strptime(s, "%a %d %b %Y")
    
      # return "{dt.day}/{dt:%m}/{dt.year}".format(dt = datetime.date(d.year, d.month, d.day)) # no time, but works fine
    return "{dt.day}/{dt:%m}/{dt.year} {dt:%H}:{dt:%M}:{dt:%S}".format(dt =     datetime.date(d.year, d.month, d.day))
    
    # print convertDateString("Mon 13 Jun 2016") # works fine, but ignores time
    print convertDateString("Mon 13 Jun 2016 10:00:00")
    

which gives ValueError: unconverted data remains: 10:00:00

Can someone please point out where am I going wrong?


Answer: I figured it out !

    
    
    # Mon 13 Jun 2016 10:00     # in
    # 13/6/2016 10:00:00        # out
    d = datetime.datetime.strptime(s, "%a %d %b %Y %H:%M")
    return d.strftime("%d/%m/%Y %H:%M:%S")
    

