instance method
beginning_of_month
Ruby on Rails 7.0.10
Since v4.0.13Signature
beginning_of_month()
Returns a new date/time at the start of the month.
today = Date.today # => Thu, 18 Jun 2015 today.beginning_of_month # => Mon, 01 Jun 2015
DateTime objects will have a time set to 0:00.
now = DateTime.current # => Thu, 18 Jun 2015 15:23:13 +0000 now.beginning_of_month # => Mon, 01 Jun 2015 00:00:00 +0000
Source
# File activesupport/lib/active_support/core_ext/date_and_time/calculations.rb, line 125
def beginning_of_month
first_hour(change(day: 1))
end
Defined in activesupport/lib/active_support/core_ext/date_and_time/calculations.rb line 125
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in DateAndTime::Calculations