Helllo, I have a query that writes some data to the database
mysql_query ("INSERT INTO PVS (time_ended)
VALUES (now())", $db_conx)
or die (mysql_error());
mysql_query ("UPDATE PVS SET break = now() WHERE id = '$id'", $db_conx)
or die (mysql_error());
What I want is to store current time + 5 minutes instead of now() for time_ended, and current time + 15 seconds instead of now() for break
Can someone show me the trick? Thank you!
Try like this
mysql_query ("INSERT INTO PVS (time_ended)
VALUES ((now() + INTERVAL 5 MINUTE))", $db_conx)
or die (mysql_error());
and
mysql_query ("UPDATE PVS SET break = (now() + INTERVAL 5 SECOND) WHERE id = '$id'", $db_conx)
or die (mysql_error());
this DATE_ADD()
help:
SELECT DATE_ADD(NOW(), INTERVAL 5 SECOND);
store current time + 5 minutes instead of now() for time_ended
INSERT INTO PVS (time_ended) VALUES (DATE_ADD(NOW(), INTERVAL 5 MINUTE)
current time + 15 sec
UPDATE PVS SET break = DATE_ADD(now(), INTERVAL 15 SECOND) WHERE id = '$id'
and all possible INTERVAL
you can find at http://www.w3schools.com/sql/func_date_add.asp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With