x days add to date format

Discussion in 'Ruby' started by aidy, Aug 10, 2008.

  1. aidy

    aidy Guest

    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
     
    aidy, Aug 10, 2008
    #1
    1. Advertising

  2. aidy

    Eric I. Guest

    On Aug 10, 11:52 am, aidy <> wrote:
    > 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 .
     
    Eric I., Aug 10, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Candy
    Replies:
    2
    Views:
    1,174
    Janaka
    Feb 18, 2004
  2. David Stockwell
    Replies:
    2
    Views:
    704
    Anna Martelli Ravenscroft
    Sep 20, 2004
  3. Gerrit
    Replies:
    0
    Views:
    391
    Gerrit
    Sep 20, 2004
  4. Terry Reedy
    Replies:
    0
    Views:
    432
    Terry Reedy
    Sep 20, 2004
  5. Replies:
    8
    Views:
    450
    Lubna tt
    Jun 26, 2005
Loading...

Share This Page