Python 24 hour timestamp format

I am currently creating timestamps using the Python time module. I created a string using this command

timestamp = time.strftime('%l:%M:%S')

      

However, this prints the format in 12 hour format. Is there a way I can do this in 24 hour format so that it displays as 20:52:53 instead of 8:52:53?

Thank!

+11


source to share


1 answer


Try

timestamp = time.strftime('%H:%M:%S')

      



Take a look at this link for information on Python timing module

http://docs.python.org/2/library/time.html

+14


source







All Articles