Reputation: 20538
I am creating a Rail 3.2 web app. In this app I got timetracking model. First the user creates a timetracking record (created_at) and then stops the same timetracking record (updated_at). How can I get the difference in seconds between these two dates? Perhaps best to have it in epoc?
I will use the result together with distance_of_time_in_words.
Thankful for all help!
Upvotes: 0
Views: 588
Reputation: 78413
Have you tried subtracting them?
>> a = Time.now
=> 2013-06-12 13:09:08 +0200
>> b = Time.now
=> 2013-06-12 13:09:11 +0200
>> b - a
=> 3.791783
Or did you mean doing this in SQL? (If so, look into your RDBMS' date and time functions/operators.)
Upvotes: 2