Forum: Ruby on Rails Simple Ruby/Rails question, doing posted hours ago

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Berlin B. (Guest)
on 2006-03-30 13:01
(Received via mailing list)
I am not the Ruby aficionado yet, if I have created_on ...timestamp.
What is a ruby way of getting the hours/minutes/seconds ago.  is there
some class that has this implemented.

For example:

Posted on 3/28/2006
Show a time with:

posted: 1 day ago
... something along those lines.

--
Berlin B.
(ramaza3 on freenode)
http://www.newspiritcompany.com
also checkout alpha version of botverse:
http://www.newspiritcompany.com:8086/universe_home
Berlin B. (Guest)
on 2006-03-30 13:01
(Received via mailing list)
Berlin B. wrote:

> ... something along those lines.
>
Of course, I could just do the math, but I didnt want make sure I wasnt
reinventing the wheel.

--
Berlin B.
(ramaza3 on freenode)
http://www.newspiritcompany.com
also checkout alpha version of botverse:
http://www.newspiritcompany.com:8086/universe_home
Kev J. (Guest)
on 2006-03-30 13:07
(Received via mailing list)
Berlin B. wrote:

>>
>> posted: 1 day ago
>> ... something along those lines.
>>
> Of course, I could just do the math, but I didnt want make sure I
> wasnt reinventing the wheel.
>
api.rubyonrails.org

I think the rails team extended the Time class for this reason
 >>
Module
ActiveSupport::CoreExtensions::Numeric::Time
In:
vendor/rails/activesupport/lib/active_support/core_ext/numeric/time.rb
<http://api.rubyonrails.org/files/vendor/rails/acti...


Enables the use of time calculations and declarations, like 45.minutes +
2.hours + 4.years.

If you need precise date calculations that doesn?t just treat months as
30 days, then have a look at Time#advance.
Kev J. (Guest)
on 2006-03-30 13:10
(Received via mailing list)
Sorry, also look at the method (rails only) distance_of_time_in_words
(ActionView)
Rob B. (Guest)
on 2006-03-30 13:28
(Received via mailing list)
Look at  distance_of_time_in_words_to_now

http://api.rubyonrails.org/classes/ActionView/Helpers/
DateHelper.html#M000465

-Rob

Rob B.		http://agileconsultingllc.com
removed_email_address@domain.invalid
+1 513-295-4739
This topic is locked and can not be replied to.