instance method
seconds_since_midnight
Ruby on Rails 7.2.3
Since v3.0.20Signature
seconds_since_midnight()
Returns the number of seconds since 00:00:00.
Time.new(2012, 8, 29, 0, 0, 0).seconds_since_midnight # => 0.0 Time.new(2012, 8, 29, 12, 34, 56).seconds_since_midnight # => 45296.0 Time.new(2012, 8, 29, 23, 59, 59).seconds_since_midnight # => 86399.0
Source
# File activesupport/lib/active_support/core_ext/time/calculations.rb, line 91
def seconds_since_midnight
to_i - change(hour: 0).to_i + (usec / 1.0e+6)
end
Defined in activesupport/lib/active_support/core_ext/time/calculations.rb line 91
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Time