Get last day of the month in Ruby

后端 未结 6 1575
-上瘾入骨i
-上瘾入骨i 2020-12-12 20:32

I made new object Date.new with args (year, month). After create ruby added 01 number of day to this object by default. Is there any way to add not first day, but last day o

6条回答
  •  心在旅途
    2020-12-12 21:04

    So I was searching in Google for the same thing here...

    I wasn't happy with above so my solution after reading documentation in RUBY-DOC was:

    Example to get 10/31/2014

    Date.new(2014,10,1).next_month.prev_day

提交回复
热议问题