查找Ruby on Rails中两个日期之间的月份数 [英] Find number of months between two Dates in Ruby on Rails
本文介绍了查找Ruby on Rails中两个日期之间的月份数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
(date2.year * 12 + date2.month) - (date1.year * 12 + date1.month)
更多信息 http://www.ruby-forum.com/topic/72120
I have two Ruby on Rails DateTime objects. How to find the number of months between them? (Keeping in mind they might belong to different years)
解决方案
(date2.year * 12 + date2.month) - (date1.year * 12 + date1.month)
more info at http://www.ruby-forum.com/topic/72120
这篇关于查找Ruby on Rails中两个日期之间的月份数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文