我需要计算从Mysql表中订阅日期到今天的天数,我需要天数。
table name : mytable
date field name : subdate
我尝试了这个,但它不起作用:
$today = CURDATE();
$subdate= ('subdate');
$days = (strtotime($today) - strtotime($subdate)) / (60 * 60 * 24);
解决了谢谢: 我的最后一个问题:
$result = mysql_query("SELECT * FROM mytable WHERE country LIKE '$country' and city LIKE '$city and (datediff(CURDATE(), age))>30");
答案 0 :(得分:5)
您可以使用datediff返回从一个日期到另一个日期的天数值
select datediff(day1, day2);
所以,
select datediff(CURDATE(), subdate) from mytable;
答案 1 :(得分:0)
试试这个
$today = CURDATE();
$subdate= ('subdate');
$days = strtotime($today) - strtotime($subdate);
echo floor($days/(60*60*24));