Came up with this snippet while writing a Rails log file parser. It will take any number of seconds and convert it to Xm Xs format (which was useful for my display purposes):
def convert_seconds_to_time(seconds)
total_minutes = seconds / 1.minutes
seconds_in_last_minute = seconds - total_minutes.minutes.seconds
"#{total_minutes}m #{seconds_in_last_minute}s"
end
convert_seconds_to_time(630)
=>"10m 30s"
I didn't need to but obviously it can be modified easily to allow for hours as well. This is small and trivial but useful.
Related posts:
WP Cumulus Flash tag cloud by Roy Tanck and Luke Morton requires Flash Player 9 or better.