i take the current date and find the last year in ruby with
1.year.ago.
so i got 2 years 2010-12-14 to 2011-12-14. My question is how to get
all
the months between these two dates in ruby in rails…? also these dates
will change depend on the current system date…
*
*
thank you
vishnu
On 14 December 2011 09:37, amvis [email protected] wrote:
i take the current date and find the last year in ruby with 1.year.ago. so
i got 2 years 2010-12-14 to 2011-12-14. My question is how to get all the
months between these two dates in ruby in rails…? also these dates will
change depend on the current system date…
What have you tried? Where have you looked for solutions? What
problems have you encountered?
@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…
Thank you
vishnu
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