DateTime in Minutes?

Hi-

So, say I have 2 DateTimes and I want to display the difference in mm:ss, how would I do this without manipulating each individual component, while still displaying the true number of minutes and seconds (i/e/ not just t.min, or t.sec)?

Thanks!

Hi-

So, say I have 2 DateTimes and I want to display the difference in mm:ss, how would I do this without manipulating each individual component, while still displaying the true number of minutes and seconds (i/e/ not just t.min, or t.sec)?

a = 15.minutes.ago

=> Tue Mar 04 12:35:08 -0800 2008

b = Time.now

=> Tue Mar 04 12:50:10 -0800 2008

b - a

=> 902.319528

"%02d" % ((b - a) / 60).to_i + ':' + "%02d" % ((b - a) % 60).to_i

=> "15:02"

Thanks!