这是我的查询:
$sql = "SELECT TIMESTAMPDIFF AS diff( DAY, (SELECT date_expire FROM tbl_rec), now())";
$query = mysql_qery($sql);
我需要一个返回,这将是php中的一个数组。
请帮忙。
答案 0 :(得分:0)
使用TIMEDIFF
获取2次
$query = "select timediff(date_expire, now()) diff
from tbl_rec;";
$rs = mysql_query($query);
$row = mysql_fetch_assoc($rs);
echo $row['diff'];
答案 1 :(得分:0)
使用以下查询日期差异。
SELECT DATEDIFF(CURDATE(),date_add) as diff FROM `Table_name`;
即仅获得日期差异。因此,对于您的表格,请参阅下面的查询
$sql = "SELECT DATEDIFF(CURDATE(),date_expire) as diff FROM `tbl_rec`;
$query = mysql_query($sql,$connection);
要查看输出,首先在mysql管理员或命令提示符下运行sql查询。
SELECT DATEDIFF(CURDATE(),date_expire) as diff FROM `tbl_rec`;
答案 2 :(得分:-1)
查询只是:
$sql = "SELECT TIMESTAMPDIFF AS diff( DAY, (SELECT date_expire FROM tbl_rec), now())";
你可以像这样生成数组(假设你使用的是MySQL):
$time= array();
$result = mysql_query($sql);
while(($row = mysql_fetch_assoc($result))) {
$time= $row['diff'];
}