pullroot
pullroot

Reputation: 3

Adding 1 day to NOW in mysql

I need a MySQL query that adds 1 day to the exact date and time that the PHP script was executed.

It needs to update the table users and pick the row where user_id=$uid, then find the column expiry_datetime and set it to exact date and time the php script was executed, + 1 day.

All the current entries in the table are 0000-00-00 00:00:00

Everything I have tried has not even come close to working, does anyone know the best way of doing this?

Upvotes: 0

Views: 208

Answers (1)

In order to add time just see here :

http://dev.mysql.com/doc/refman/5.6/en/date-and-time-functions.html

It should help you, I think you already know to update a specific column of a specific row.

To get the date when php script was executed, you may use http://php.net/manual/fr/function.date.php or the "NOW()" mysql function.

I think I'll do the date calculation in php and then juste update the row in SQL, but you can do all the operation with MySQL.

Upvotes: 1

Related Questions