x days add to date format

A

aidy

Hi,

Can anyone tell me how I can add 10 days to this date format please?

Time.now.localtime.strftime("%d-%b-%Y")

Thanks

Aidy
 
E

Eric I.

Can anyone tell me how I can add 10 days to this date format please?

Time.now.localtime.strftime("%d-%b-%Y")

SECONDS_PER_DAY = 60 * 60 * 24
(Time.now + 10*SECONDS_PER_DAY).localtime.strftime("%d-%b-%Y")

Ideally you want to do the date/time manipulations before converting
to a String. Otherwise you have to parse the string, do the date
manipulations, and convert back to a String.

Eric

====

Rails and Ruby training available at http://LearnRuby.com .
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top