Displaying 1 result from an estimated 1 matches for "number_of_days".
2006 Feb 28
5
Getting number of days in a month
...ument you could pass to the Date function to
get the number of days in the current month:
echo date("t"); // Outputs "28" for February
I don''t see anything like this in Ruby/Rails. Right now, I''m using a
very ugly line to pull the last day of the month:
@number_of_days = (Date.strptime(Date.today.strftime("%Y-%m-01")) >>
1) - 1
Basically, it takes the first day of the current month, adds one
month, and then subtracts one day. Am I completely overlooking some
obvious and easy way to do this? (I''m assuming so).