Rails 3 time output
- by Oluf Nielsen
Hi, I'm now working on my output of the feeds I'm taking in from some site. What I'm currently doing is Time, and i want it to be displayed in a maybe, little be special way.. like this..
today, 14:12
yesterday, 15:34
27/12, 15:24
i have this in my code
= news.entry_published.strftime("%d/%m, %H:%M")
That gives me an error saying
undefined method `strftime' for "2010-12-30 19:26:00.000000":String
And it dosn't do what i want with the days..
Edit:
- @date = DateTime.strptime(news.entry_published, "%Y-%m-%d %H:%M:%S")
= @date.strftime("%d/%m, %H:%M")
Now works, and gives this output
30/12, 19:26
But i still have to check if it is today, yesterday or just another day.
Cheers, Oluf.