I need to calculate a date that is exactly 31 days from the current
date in YYYY-MM-DD format. I know that Date.today returns the
current date, but how can I add 31 days to this value? I’m sure this
task is simple, but I haven’t been able to figure it out.
sender: “Toine” date: “Tue, Feb 06, 2007 at 08:00:06PM +0900” <<<EOQ
Date.today + 31 and Time.now + 312460*60 yield the same results.
Just beware that although they yield the same result they do it at very different speeds:
2007-02-08
2007-05-19
Thu Feb 08 22:05:49 W. Europe Standard Time 2007
Sat May 19 23:05:49 W. Europe Daylight Time 2007
Looks innocent enough, but when I run the same program again in 60
minutes,
Time.now + 1006060 would output:
Sun May 20 00:05:49 W. Europe Daylight Time 2007 (which is my birthday
by
the way).
So from a correctness point of view, use Date when you are dealing with
dates,
and use Time when you are dealing with time.