John Merlino
2013-Sep-26 21:35 UTC
find total months passed between two ActiveSupport::TimeWithZone objects
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? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/ee22138c-7949-4ebb-b1d6-1776362c4f99%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Matt Jones
2013-Sep-27 13:37 UTC
Re: find total months passed between two ActiveSupport::TimeWithZone objects
On Thursday, 26 September 2013 16:35:30 UTC-5, John Merlino wrote:> > 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? >(Time.zone.now - unit.created_at) / 1.month, perhaps? --Matt Jones -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/2746525b-d34d-44f8-bcfb-63e5744f3d18%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.