How do you subtract from a datetime?

Viewed 32686

I'd like to write a simple function to say in hours:

How much time has passed since this has been created?

My attempts:

-time = DateTime.now.hour - (self.created_at.hour)

Does anyone know how to do this in Ruby on Rails?

3 Answers
Related