python - time.strftime() not updaing -
i trying time when button pushed, going have few pushes without starting , calling time module. in ipython, tested out code, , time not updating
import time t = time.strftime("%b-%d-%y @ %i:%m%p") print(t) #do else little t = time.strftime("%b-%d-%y @ %i:%m%p") print(t)
it gives me same time
even if put in time tuple such as:
lt = time.localtime(time.time()) t = time.strftime("%b-%d-%y @ %i:%m%p", lt) print(t)
i same time
even if wait, , execute code again (in ipython), gives me same time.
time.time() give me new time every time though
i don't know if doing in ipython (i'm testing code before put in python file) matters
what doing wrong??
you using %m
@ %i:%m%p
format "minutes", means month in decimals. try capital %m
instead minutes.
so,
time.strftime("%b-%d-%y @ %i:%m%p")
see strftime documentation format directives.
Comments
Post a Comment