Formatting time in Python? -


how go formatting time in python?

lets have

time = 9.122491 

the time in hours , need convert h:m format. desired output should be:

9:07 

any appreciated!

using datetime module:

>>> datetime import datetime, timedelta >>> mytime = 9.122491 >>> temp = timedelta(hours=mytime) >>> print((datetime(1, 1, 1) + temp).strftime('%h:%m')) 09:07 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -