On 14 December 2011 19:45, amvis <[email protected]> wrote:
> @lastyear = 1.year.ago. it will give the last year. but it will  shows date
> with time.
>
> 2010-12-14 19:44:28 UTC
>
> How to avoid that time...? i have to get only the date 2010-12-14...

Have a look at the documentation for the Time class, there are many
methods that you can use.
When you say you want to "get" the date do you mean you want it in a
variable or you want to convert it to a string for display?
If you want it in a variable then you can make a new Time object using
day, month, year from original one (leaving hours, mins, seconds as
zero so it represents the start of the day).  If you want it as a
string then look at strftime.

Colin

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to