Saturday, July 29, 2006

Calculating time difference

Here is a Ruby on Rails function I wrote that returns time difference in minutes. It can be easily modified to return time difference in seconds, hours etc.


def time_diff_in_minutes (time)
diff_seconds = (Time.now - time).round
diff_minutes = diff_seconds / 60
return diff_minutes
end

0 Comments:

Post a Comment

<< Home

eXTReMe Tracker