Formatting Time

O

Ognjen Bezanov

I never thought id need help with such a thing as time formatting
(admittadly i never did it before) but ok, i guess there is a first for
everything.

I have a float variable representing seconds, and i want to format it
like this:

0:00:00 (h:mm:ss)

Now search as I might i am finding this quite elusive, i had a look at
the time module but that seems overly complicated for this. Anyone got
any simple solutions to doing this? cheers!
 
A

Andrew Dalke

Ognjen said:
I have a float variable representing seconds, and i want to format it
like this:

0:00:00 (h:mm:ss)
.... m, s = divmod(t, 60)
.... h, m = divmod(m, 60)
.... return "%d:%02d:%02d" % (h, m, s)
....
Andrew
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,206
Latest member
SybilSchil

Latest Threads

Top