Reputation: 15
I have the folling line of code which returns the hour, but how do i get hours and minutes, preferable in this format 7:45.
print(time.localtime().tm_hour)
been racking my brain for hours trying to solve this but i am only new to python lol.
Thank you in advance for your help.
Upvotes: 1
Views: 1141
Reputation: 57075
Function strftime()
displays the local time by default:
time.strftime('%H:%M')
#'03:34'
Upvotes: 1