Reputation: 2245
I have a table with time column.
CREATE TABLE `mbusGuestCodeExpires` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`hashOfUser` int(11) NOT NULL,
`expiresTime` time DEFAULT NULL,
`active` int(1) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `hashOfUser` (`hashOfUser`),
UNIQUE KEY `id` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8 PACK_KEYS=0;
and input which has value of this field and user can change it, where $expireTime
is time from table and $timeDiffHour
and $timeDiffMinute
are time left to time from table.
echo "<div class='expires'>Expires:<input type='text' class='expiresTime' value='{$expireTime}'/></div><div class='left'>";
if (($timeDiffHour>=0) && ($timeDiffMinute>0))
{
echo"Left:".$timeDiffHour."h. ".$timeDiffMinute." min.";
}
echo"</div>";
I need now change the field active to 0 when it is $expireTime
time. What is the best way to do it except running cron script every minute that check all the column and checks its value if it's less current time?
Upvotes: 1
Views: 43
Reputation: 360602
How about:
select ... where expiresTime < curtime()
Doc ref: http://dev.mysql.com/doc/refman/5.6/en/date-and-time-functions.html#function_curtime
Upvotes: 1