[Ruby on Rails] Get the last date of the month in ruby on rails

dd = 11 # which means tha month november
dd_end_txt = `date -d "#{mm}/1 + 1 month - 1day"`
# which returns "Sat Nov 30 00:00:00 IST 2013\n"
dummy = dd_end_txt.split(" ")
dd_end = dummy[2] if(dummy != nil)

# Result is 30

No comments:

Post a Comment