Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

24 hour format for Python timestamp

Tags:

Currently I'm creating timestamps with the Python time module. I created a string using this command

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

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

Thanks!

like image 312
LandonWO Avatar asked Feb 05 '13 04:02

LandonWO


People also ask

What is 24 hour format datetime?

The pattern dd/MM/yyyy hh:mm:ss aa is used for the 12 hour format and the pattern MM-dd-yyyy HH:mm:ss is used for the 24 hour format.


1 Answers

Try

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

Check out this link for info on Python time module

https://docs.python.org/3/library/time.html#time.strftime

like image 139
mcd Avatar answered Sep 30 '22 05:09

mcd