1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Rep Power
    I have a php script that processes a form and enters data into a mySQL database. Two of the fields that are entered are dates. One - when it was processed (I use the now() function) and one that would be an expiration date. I am using datetime field types in mySQL.

    I need to automaticall add 90 days to the expiration date. Is there a way to do this that is easy like NOW() + 90 days or some thing...

    Please help - it is all I need to figure out and then I can use this baby!
  2. #2
  3. No Profile Picture
    Devshed Newbie (0 - 499 posts)
    To add a period of time, in terms of a whole
    day.. here's a little sample

    $days = 90;

    $expires = time() + (86400 * $days);

    86400 is the number of seconds in a given day.

    In short, now $expires is equal to this "time()" 90 days from today.

    SnR Graphics,
    Low Cost Hosting and Web Development.
  4. #3
  5. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Niagara Falls (On the wrong side of the gorge)
    Rep Power
    Robert, that would require three queries to the db.

    MW, check out the date_add() function in mysql.

    insert into table_name (added,expires) values (now(),date_add(now(),interval 90 day));

Similar Threads

  1. current date and current date + 7 days
    By rjstephens in forum Perl Programming
    Replies: 2
    Last Post: January 28th, 2004, 04:47 AM
  2. Add (no) of working days only to a date
    By newbie10 in forum PHP Development
    Replies: 4
    Last Post: January 15th, 2004, 04:45 AM
  3. caluclating date + 30 days . .
    By rix in forum Visual Basic Programming
    Replies: 3
    Last Post: November 28th, 2003, 07:14 AM
  4. adding days to a date
    By lottos in forum MySQL Help
    Replies: 1
    Last Post: November 18th, 2003, 07:26 PM
  5. Adding to a date held on a MySQL DB
    By chrispeat2003 in forum PHP Development
    Replies: 2
    Last Post: November 4th, 2003, 09:38 AM

IMN logo majestic logo threadwatch logo seochat tools logo