select * from xx where times between 当前时间 到 当前时间加上7分钟 之间例如 select * from xx where times between 0010 到 0017 之间 (代表0点10分到0点17分之间)如果当前分钟是57分钟。应该是到下个小时的第4分钟,而不是57-64之间0057--0104这里应该怎么判断
mysql方法 $sql = "SELECT * from xx where times between DATE_FORMAT(now( ) , '%H%i' ) AND DATE_FORMAT( DATE_ADD( now( ) , INTERVAL 7 MINUTE ) , '%H%i' )";未测试,仅供参考
$curTime = time();
$secTime = time()+7*60;
$sql = "select * from xx where times between '$curTime' and '$secTime'";
结合php我是这样
mysql 的时间函数不熟-。-
$secTime = date('Y-m-d',time()+7*60);
datetime类型$curTime = date('Y-m-d H:i:s',time());
$secTime = date('Y-m-d H:i:s',time()+7*60);
那就是$curTime = date('Hi',time());
$secTime = date('Hi',time()+7*60); 就这样了
time()当前时间戳
后面那个七分钟过后
怎么不是了???
$sql = "SELECT * from xx where times between DATE_FORMAT(now( ) , '%H%i' ) AND DATE_FORMAT( DATE_ADD( now( ) , INTERVAL 7 MINUTE ) , '%H%i' )";未测试,仅供参考