September 7, 200916 yr I have a little bit of code that i need to take the date from my database and ad 1 year to it. So far I have found this code <?php $date = "binding goes in here????"; $newdate = strtotime ( '+1 year' , strtotime ( $date ) ) ; $newdate = date ( 'Y-m-d' , $newdate ); echo $newdate; ?> but when I try inserting the database binding into the "" in the first line it all goes wrong. The binding in its simplest format looks like this <?php echo $row_renew_list['date']; ?> So what is the syntax for inserting this into the ""
September 8, 200916 yr Do you need to format the time as a string - $strDate= date ( string $format [, int $timestamp ] ) where 'timestamp' comes from the database? See date() in PHP manual.
September 9, 200916 yr easyer to just select with the additional year; mysql_query("SELECT DATE_SUB(`date_field`, INTERVAL -1 YEAR) as `new_date_field` FROM `date_table`");
Create an account or sign in to comment