Ruby on Rails Friday, September 27, 2013



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@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
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.

No comments:

Post a Comment