欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

求解一个php难题 是一个时间比较有关问题

程序员文章站 2024-01-11 20:36:58
...
求解一个php难题 是一个时间比较问题
总是出的数据是0,是不是需要转换一下数据格式啊 数据库时间是年:月:日 小时分秒 ,我是不是需要转成年月日啊,关键是如何转换啊 小弟亏求
for ($i = 0; $i $tomorrow = mktime(0,0,0,date("m"),date("d")-$i,date("Y"));
$sql="select count(*) from customers_info where customers_info_date_account_created='".date("Y-m-d", $tomorrow)."'";
$result=mysql_query($sql,$conn) or
die("Error:".mysql_error);
$row=mysql_fetch_row($result);
echo $row[0]."
";
}
?>



------解决方案--------------------
$sql="select count(*) from amp_test where date between '".date("Y-m-d", ($tomorrow-3600*24))."' and '".date("Y-m-d", $tomorrow)."'";
输出:
1257292800select count(*) from amp_test where date between '2009-11-03' and '2009-11-04'2
1257206400select count(*) from amp_test where date between '2009-11-02' and '2009-11-03'1
1257120000select count(*) from amp_test where date between '2009-11-01' and '2009-11-02'0
我测试用的数据库里的格式是timestamp , 2009-11-04 11:13:25这种
------解决方案--------------------
可以使用DATE_FORMAT(your_field, '%Y-%m-%d') = ...来转换
求解一个php难题 是一个时间比较有关问题

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。

相关文章

相关视频