Charanya Nagarajan
2009-May-12 11:48 UTC
converting created_at to the number of days ago format
Hi I want to display the created_at field of my model in the format n days ago n hours ago Please help me in this -- Posted via http://www.ruby-forum.com/.
Vladimir Rybas
2009-May-12 12:38 UTC
Re: converting created_at to the number of days ago format
@seconds_from_model_creation = (Time.now.to_i - Time.at (@model.created_at).to_i) @days_from_creation = @seconds_from_model_creation / (60*60*24) ... On May 12, 6:48 pm, Charanya Nagarajan <rails-mailing-l...@andreas- s.net> wrote:> Hi > > I want to display the created_at field of my model in the format n days > ago n hours ago > > Please help me in this > -- > Posted viahttp://www.ruby-forum.com/.
Vladimir Rybas
2009-May-12 12:49 UTC
Re: converting created_at to the number of days ago format
Sorry, that should be (Time.now.to_i - Time.at(@model.created_at.to_i).to_i) and there are questions about timezones and stuff. You need to watch it carefully. On May 12, 7:38 pm, Vladimir Rybas <VladimirRy...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> @seconds_from_model_creation = (Time.now.to_i - Time.at > (@model.created_at).to_i) > @days_from_creation = @seconds_from_model_creation / (60*60*24) > ... > > On May 12, 6:48 pm, Charanya Nagarajan <rails-mailing-l...@andreas- > > s.net> wrote: > > Hi > > > I want to display the created_at field of my model in the format n days > > ago n hours ago > > > Please help me in this > > -- > > Posted viahttp://www.ruby-forum.com/.
Charanya Nagarajan
2009-May-14 04:44 UTC
Re: converting created_at to the number of days ago format
Vladimir Rybas wrote:> Sorry, that should be > (Time.now.to_i - Time.at(@model.created_at.to_i).to_i) > > and there are questions about timezones and stuff. You need to watch > it carefully.Thank you Vladimir -- Posted via http://www.ruby-forum.com/.