Try the to_time method
eg
news.created_at.to_time
----- Original Message -----
From: Chris Lloyd
To: Rails@lists.rubyonrails.org
Sent: Friday, July 14, 2006 8:47 AM
Subject: [Rails] Converting Date string to Time Object
Hi,
I have MySQL model with created_on specified as :date. This means that the day
the record was created on is stored in the database as a string like
"2006-04-28". I want to be able output a something like "5 days
ago". From looking in the API I''ve found " strftime" and
"distance_of_time_in_words". Distance_of_time_in_words only accepts
Time objects and integers, so I guess my question is how do I convert "
news.send("created_at")" to either a Time object or a integer?
I''ve tried a few things like
"news.send("created_at").to_i" but nothing works.
I''m sure that there is probably some helper which will let me do this
but I''m not sure what it is.
Any help will be greatly appreciated.
Chris
------------------------------------------------------------------------------
_______________________________________________
Rails mailing list
Rails@lists.rubyonrails.org
http://lists.rubyonrails.org/mailman/listinfo/rails
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060714/0abf98df/attachment.html