Newbie: How do I convert "about 2 hours ago" to "today"?

I’m using distance_of_time_in_words to generate friendly text but not
sure it’s the right method to say something was entered “today”.

Is there an option or other process to use to achieve the text reading
“today” rather than about xx hours ago? I’marst ting to think I need to
create a new helper method or edit the configs or something.

Thanks,
DAN

I’m not sure if there is an existing way that is clean… but here
is the beginings of a possible solution?

SECONDS_IN_DAY = 606024
time_of_post = Time.gm(2000,“jan”,1,20,15,1).to_i

if (Time.now.to_i - time_of_post) <= SECONDS_IN_DAY
# print ‘today’
elsif (Time.now.to_i - time_of_post) <= SECONDS_IN_DAY*2
# print ‘yesterday’
else
# use distance_of_time_in_words
end

DAN wrote:

I’m using distance_of_time_in_words to generate friendly text but not
sure it’s the right method to say something was entered “today”.

Is there an option or other process to use to achieve the text reading
“today” rather than about xx hours ago? I’marst ting to think I need to
create a new helper method or edit the configs or something.

module ApplicationHelper
def today_or_time_ago_in_words(time)
(time.to_date == Time.now.to_date ? ‘today’ :
time_ago_in_words(time))
end
end

today_or_time_ago_in_words(Time.new)
=> “today”

today_or_time_ago_in_words(Time.gm(2006, “Dec”, 1, 11, 0, 0))
=> “6 days”

Cheers,

Mark