find total months passed between two ActiveSupport::TimeWithZone objects

18 views
Skip to first unread message

John Merlino

unread,
Sep 26, 2013, 5:35:30 PM9/26/13
to rubyonra...@googlegroups.com
unit.created_at.class
 => ActiveSupport::TimeWithZone 

 Time.zone.now.class
 => ActiveSupport::TimeWithZone 


 Time.zone.now - unit.created_at
 => 47709736.32316899 

I think that's the number of seconds that have passed between when the unit was created and the current time. Is this correct? If so, is there any easier way to find the total months that passed between two time objects like this?

Matt Jones

unread,
Sep 27, 2013, 9:37:04 AM9/27/13
to rubyonra...@googlegroups.com
(Time.zone.now - unit.created_at) / 1.month, perhaps?

--Matt Jones 
Reply all
Reply to author
Forward
0 new messages