Adding time at which tweet or any text created in rails

So, for adding time use the above code
if tweet or text was added before 24 hours then it will display as 2 hours ago or 4 hours ago and if more than a day time then it will display date.
<% if tweet.created_at > Time.now.beginning_of_day %>
<%=”#{time_ago_in_words(tweet.created_at)} ago”%>
<% else %>
<%= tweet.created_at.strftime(“%b %d, %Y”) %>
<% end %>
enjoy!

Leave a comment