How Do I Record "Today's Date + 30 Dyas

Discussion in 'Programming' started by Gugel, Oct 26, 2007.

  1. #1
    All-wise and knowing DP, I need your help.

    On a form, I have an option in a drop-down menu that reads "Flexible Date". When someone selects that option, I need it to record to the database (Coldfusion if its relevant) as Today's Date + 30 days. In other words, let's say today is Oct. 1st and the user select "Flexible Date". When they submit the form, it should be recorded in the database as Oct. 31st.

    Any ideas on how this can be done? Thanks!

    *Mods, please change the title to How Do I Record "Today's Date + 30 Days" to a Database?*
     
    Gugel, Oct 26, 2007 IP
  2. Gugel

    Gugel Peon

    Messages:
    38
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Damnit, my finger slipped onto the Enter key as I was typing in the title.
     
    Gugel, Oct 26, 2007 IP
  3. gota

    gota Peon

    Messages:
    20
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    What is the database type? What is the column/field type that holds the date?
     
    gota, Oct 26, 2007 IP
  4. tonybogs

    tonybogs Peon

    Messages:
    462
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Try something like this

    $date = date('Y-m-d', strtotime('+ 30 days'));

    (this should work but im away from my devleopment box sorry :) )
     
    tonybogs, Oct 26, 2007 IP
  5. scriptman

    scriptman Peon

    Messages:
    175
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #5
    A more efficient option would be $date = time() + 43200;

    (I don't frequently work with time so I may be overlooking something).

    Edit: Haha.. How did I mess up that calculation? The above number should be 2592000 - thanks krakjoe. However it appears my comment is entirely useless because I'm talking in the wrong language. Whoops.
     
    scriptman, Oct 27, 2007 IP
  6. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #6
    there are 86400 seconds in a day, you're sort of overlooking that .... also the user said he's using ColdFusion ...
     
    krakjoe, Oct 27, 2007 IP