I have 2:00 in a table and I would like to subtract 0:01 from it. I have tried in a recent post before this one, but it is no help.
In PHP and MySQL, how would I subtract 1 second from 2 minutes?
if (isset($_GET['id']) && isset($_GET['time'])) {
mysql_select_db("aleckaza_pennyauction", $connection);
$query = "SELECT Current_Time FROM Live_Auctions WHERE ID='1'";
$results = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_array($results)) {
$newTime = $row['Current_Time'];
$query = "INSERT INTO Live_Auctions(Current_Time) VALUES('".$newTime."')";
$results = mysql_query($query) or die(mysql_error());
}
}
Thanks.
Check
http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html for MySQL functions,
and http://www.php.net/manual/en/datetime.sub.php for PHP.
PHP: time():
This, -1, into PHP date() should do the trick.
You can do it straight on the DB using MySQL
SUBTIME()
Or you can get the time from MySQL and do it on PHP using
DateTime::sub()
Check this code in php flavor, with what u provided-