Posted By

endorfin on 03/19/09


Tagged

rubyonrails


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

sionnnn
webstic
octoberborn


Seconds to Minutes/Seconds


 / Published in: Rails
 

URL: http://www.perplexedlabs.com/2008/02/08/seconds-to-minutesseconds-in-rails/

convertsecondsto_time(630) =>"10m 30s"

  1. def convert_seconds_to_time(seconds)
  2. total_minutes = seconds / 1.minutes
  3. seconds_in_last_minute = seconds - total_minutes.minutes.seconds
  4. "#{total_minutes}m #{seconds_in_last_minute}s"
  5. end

Report this snippet  

You need to login to post a comment.