pythontime

How can I get the seconds of the time in Python?


This is my code:

last_time = get_last_time()
now = time.time() - last_time
minute = 
seconds = 
print 'Next time you add blood is '+minute+':'+seconds

Because recovery blood every 5 minutes so only need minute and second.


Solution

  • This is basic time arithmetics...if you know that a minute has 60 seconds then you could have found that yourself:

    minute = now // 60
    seconds = now % 60
    

    Or if you want integers (discarding fractional seconds),

    minute = int(now // 60)
    seconds = int(now % 60)