insert now plus a year
Posted: Sun Jul 01, 2007 8:22 pm
How would you insert now() plus one year? In mysql... thanks!
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
<?php
//get the date for now
$now = date('Y-m-d');
//get the date for 1 year from now
$newdate = mysql_query("SELECT Date_Add('$now', INTERVAL 1 Year) as newdate") or die("error". mysql_error());
$newdate_row = mysql_fetch_assoc($newdate);
$newdate_value = $newdate_row['newdate'];
?>
Code: Select all
INSERT INTO table SET `date`= DATE_ADD(NOW(), INTERVAL 1 YEAR)