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!
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With