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
Coates, Steve (ACHE) wrote:
import time
t=36100.0
time.strftime('%H:%M:%S',time.gmtime(t))
> '10:01:40'
But if t>=24*60*60 then H cycles back to 0
>>> import time
>>> t=24*60*60
>>> time.strftime('%H:%M:%S',time.gmtime(t))
'00:00:00'
>>>
Andrew
Am Fri, 03 Jun 2005 09:29:41 +0100 schrieb 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 t
quoth the 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
> -Original Message-
> From: Ognjen Bezanov [mailto:[EMAIL PROTECTED]
> Sent: 03 June 2005 09:30
> To: python-list@python.org
> Subject: Formatting Time
>
> I never thought id need help with such a thing as time
> formatting (admittadly i never did it before) but
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
[EMAIL PROTECTED] top-posted:
> May be
>
>
sec = 2472
"%d:%02d:%02d" % (int(sec/360), int(sec % 360 /60), int(sec % 60))
>
> '6:05:12'
>
Could you possibly have meant 3600 instead of 360?
--
http://mail.python.org/mailman/listinfo/python-list
May be
>>> sec = 2472
>>> "%d:%02d:%02d" % (int(sec/360), int(sec % 360 /60), int(sec % 60))
'6:05:12'
Regards
-Mensaje original-
De: Ognjen Bezanov [mailto:[EMAIL PROTECTED]
Enviado el: Jueves, 02 de Junio de 2005 03:29 p.m.
Para: python-list
Ognjen Bezanov wrote:
> I have a float variable representing seconds, and i want to format it
> like this:
>
> 0:00:00 (h:mm:ss)
>>> def format_secs(t):
... m, s = divmod(t, 60)
... h, m = divmod(m, 60)
... return "%d:%02d:%02d" % (h, m, s)
...
>>> format_secs(0)
'0:00:00'
>>> format_sec
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
10 matches
Mail list logo