July 11th, 2000, 11:03 PM
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!
July 12th, 2000, 12:37 AM
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.
Low Cost Hosting and Web Development.
July 12th, 2000, 06:40 AM
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));