【发布时间】:2017-02-23 06:34:20
【问题描述】:
我只想在testfrom 日期为todays 且testto 日期未结束时才显示数据库记录。
我在下面尝试的以下代码似乎无法正常工作,有人可以看看我做错了什么吗?
数据库中存储的日期值是
testfrom - 2017-02-23 00:00:00
testto - 2017-02-24 23:59:59
我的代码
$dt = date("Y-m-d");
$srt = date("Y-m-d", strtotime($r['testfrom']));
$end = date("Y-m-d", strtotime($r['testto']));
if($srt >= $dt || $end <= $dt){
}
这是正确的方法吗?
珍惜你宝贵的时间
【问题讨论】:
标签: php mysql date-comparison