1
1
这可以帮助您: http://www.francisfish.com/getting_the_number_of_months_between_two_dates_in_rubyrails.htm 获取月数后,您可以从此处获取月名: months = ["", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"] months[start_date.month, number_of_months]
如
编辑:
Date::MONTHNAMES[start_date.month, number_of_months]
编辑:
Date::MONTHNAMES[start_month_num, end_month_num] 但是,如果end-month-num小于start-month-num,这将失败。 这应该有效: if start_month <= end_month Date::MONTHNAMES[start_month..end_month] else Date::MONTHNAMES[end_month..12] + Date::MONTHNAMES[1..start_month] end |