John John - 6 months ago 8
Ruby Question

How to get start day and end day of a particular month and year in ruby?

Iam having the

month
value like
(1 to 12)
and
year
value like
2011 to 2012
by passing these parameters i want to get the
starting day
and
ending day
of the paticular
month
and
year
. how can i do this in ruby?

Answer

Date.civil sounds like what you need

start_date = Date.civil(2011, 1, 1)  #=> Sat, 01 Jan 2011
end_date = Date.civil(2011, 12, -1)   #=> Sat, 31 Dec 2011

Docs: here