Praveen Singh wrote: > How can i convert this- > >>>>time24hr('12:34am') > '0034hr' > > i searched in date module but i am not able to figure out what how to do > this...
>>> time.strftime("%H:%M", time.strptime("12:34am", "%I:%M%p")) '00:34' >>> datetime.datetime.strptime("12:34am", "%I:%M%p").strftime("%H:%M") '00:34' >>> datetime.datetime.strptime("12:34am", "%I:%M%p").strftime("%H:%Mhr") '00:34hr' The supported formats are explained here: http://docs.python.org/library/time.html#time.strftime _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor