instance method seconds_since_midnight

Ruby on Rails 7.2.3

Since v3.0.20

Available in: v3.0.20 v3.1.12 v3.2.22.5 v4.0.13 v4.1.16 v4.2.9 v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

seconds_since_midnight()

Returns the number of seconds since 00:00:00.

DateTime.new(2012, 8, 29,  0,  0,  0).seconds_since_midnight # => 0
DateTime.new(2012, 8, 29, 12, 34, 56).seconds_since_midnight # => 45296
DateTime.new(2012, 8, 29, 23, 59, 59).seconds_since_midnight # => 86399
Source
# File activesupport/lib/active_support/core_ext/date_time/calculations.rb, line 20
  def seconds_since_midnight
    sec + (min * 60) + (hour * 3600)
  end

Defined in activesupport/lib/active_support/core_ext/date_time/calculations.rb line 20 · View on GitHub · Improve this page · Find usages on GitHub

Defined in DateTime

Type at least 2 characters to search.

↑↓ navigate · open · esc close