-2

I need a little help. I'm try to UPDATE a datetime to MySQL, but it didn't work.

The declaration is like this:

    $startDate = time();
    $time = date("Y-m-d H:i:s", strtotime('+7 days', $startDate));

After this i want to UPDATE, but in MySQL is still blank always.

UPDATE:

mtquery("UPDATE table SET end_time = ".$time." WHERE id = ".$table['id']."");

If i use NOW() instead of ".$time.", it works perfectly.

If someone can help, please write the solution.

Thanks,

KoLi

KoLi
  • 39
  • 3

1 Answers1

0

Instead of PHP time(), you can use MySQL date time functions

You can use MySQL query as

UPDATE table SET end_time = DATE_ADD(NOW(), INTERVAL 7 DAY) WHERE id = "'".$table['id']."'"
PravinS
  • 2,640
  • 3
  • 21
  • 25