What's the most efficient way get the first day of the current month?

后端 未结 8 1856
心在旅途
心在旅途 2021-02-12 11:55

With ruby I\'m trying to get format a date as such: 2009-10-01

Where I take the current date (2009-10-26) and then change the day to \"01\".

I know of ways to do

相关标签:
8条回答
  • 2021-02-12 12:53
    require 'active_support/core_ext'
    Date.today.beginning_of_month
    
    0 讨论(0)
  • 2021-02-12 12:59

    Like

    Date.today.beginning_of_day
    Date.today.end_of_day
    

    And

    Date.today.beginning_of_week
    Date.today.end_of_week
    

    There also is

    Date.today.beginning_of_year
    Date.today.end_of_year
    
    0 讨论(0)
提交回复
热议问题