On Feb 6, 2:47 am, Sharon Phillips <phillip... / yahoo.co.uk> wrote:
> Hi,
>
> This is something that took me ages to figure out because it is so
> simple :)
> Just add the number of days, eg future_date= Date.today+31
>
> Cheers,
> Dave
>
> On 06/02/2007, at 9:40 PM, Farrel Lifson wrote:
>
> > On 06/02/07, Toine <bapo... / gmail.com> wrote:
> >> Hello,
>
> >> I'm new to Ruby so please bare with me...
>
> >> 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.
>
> >> Thanks
>
> > Time now + number of seconds in 31 days
> > Time.now + 31*24*60*60
> > which is equivalent to
> >  Time.now + 2678400
>
> > Farrel

Date.today + 31 and Time.now + 31*24*60*60 yield the same results.

Thanks for your help.