I have two columns in my db: start_date
and end_date
, which are both DATE
types. My code is updating the dates as follows:
You do not actually need PHP functions to achieve this. You can already do simple date manipulations directly in SQL, for example:
$sql1 = "
UPDATE `users` SET
`start_date` = CURDATE(),
`end_date` = DATE_ADD(CURDATE(), INTERVAL 1 MONTH)
WHERE `users`.`id` = '" . $id . "';
";
Refer to http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_addtime