How do I get the number of seconds between two DateTimes in Ruby on Rails

后端 未结 8 1745
庸人自扰
庸人自扰 2020-12-23 15:37

I\'ve got code that does time tracking for employees. It creates a counter to show the employee how long they have been clocked in for.

This is the current code:

8条回答
  •  执念已碎
    2020-12-23 16:21

    I am using ruby-2.1.4 and for me the following worked

    Time.now - Time.new(2014,11,05,17,30,0)
    

    gave me the time difference in seconds

    reference: ruby doc

提交回复
热议问题