SEC to minutes

Hi Friends,

I am new to ruby on rails.

I want to convert seconds to minutes.

like if 220sec= 3.40 minutes
I did in this way sec/60 but it giving the false results

ex : 70 sec = 110/6=1.8 but it is worong as for time

Can u give any advice?

On 3/15/07, Karni [email protected] wrote:

Hi Friends,

I am new to ruby on rails.

I want to convert seconds to minutes.

like if 220sec= 3.40 minutes

Nope:) 220 sec = 3 and 2/3 minutes, or 3.667
Which you can easily find out by 220 / 60.0
(Make sure you include the .0… forces it to float and keeps the stuff
after the decimal point, which 220 / 60 would not)

I think he meant 3 minutes 40 seconds by 3.40 minutes. I think. I
wouldn’t
have put it that way but the math works.

RSL

On Mar 15, 2007, at 9:35 AM, Luke I. wrote:

Which you can easily find out by 220 / 60.0
(Make sure you include the .0… forces it to float and keeps the
stuff after the decimal point, which 220 / 60 would not)

Perhaps you mean 220sec => 3:40

class Integer
def to_minutes
“%d:%02d” % [ self/60, self%60 ]
end
end

220.to_minutes
=> “3:40”

-Rob

Rob B. http://agileconsultingllc.com
[email protected]

Great minds think alike!

RSL

Ahhh…

Russell N. wrote:

Great minds think alike!

RSL

Very thankful to all ,i got solution…
Thanks alot