Date/Time cheat sheet

Get the last date of the month

Date.civil(2023, 02, -1)
#=> Tue, 28 Feb 2023

Check time in the future or the past

Time.current.past?
#=> true

1.day.ago.past?
#=> true

1.day.from_now.future?
#=> true

Format the time

# config/initializers/datetime_formats.rb
Date::DATE_FORMATS[:detail] = '%a, %d %b, %Y at %H:%M'

# use
Time.now.to_s(:detail)
#=> "Thu, 24 Nov, 2022 at 22:20"