I’m having a little bit of trouble with getting an incremented date into an MySQL database. The field is of type DATE.
First of all I increment the date with the following code:
if($_POST['membershipLength'] == "6 Months") {
$renew = mktime(0, 0, 0, date("m")+9, date("d"), date("y"));
}
Then I wish to enter: date("m/d/y", $renew) into the column in the database.
Can anyone see where I’m going wrong? The value it inserts consists of 0s which I’m assuming is the default.
The MYSQL date field has the following format “Y-m-d” so something like “2010-11-04”. You’re trying to insert a value as “2010/04/11”. Change your first parameter to “Y-m-d” and it should work 🙂