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:
Subtracting two DateTimes returns the elapsed time in days, so you could just do:
elapsed_seconds = ((end_time - start_time) * 24 * 60 * 60).to_i