这是我的事件脚本,用于提取接下来 7 天的约会,它似乎工作正常,但仅在一种情况下........日期和时间以日期时间格式保存在 mysql 数据库中,所以 2013- 12-23 08:30:00。我的脚本每天都会打印出来,并为要下车或取货的客户找到当天的约会。mysql 查看数据库并将客户与下车或取货字段匹配到打印日期,并将它们添加到日期下方的 div 中。
我遇到的问题是,如果时间设置为 00:00:00 以外的任何时间,则当天不会接听该客户。如何让比较忽略时间而只使用日期?
// Date box container
echo '<div class="dateboxcontainer">';
// Loop through and create a date for the next 7 days
$days = new DatePeriod(new DateTime, new DateInterval('P1D'), 7);
foreach ($days as $day) {
echo '<div class="datebox">';
echo '<div class="topdate">';
echo strtoupper($day->format('D d')) . PHP_EOL;
echo '</div>';
// Get the names for each day
$theday = strtoupper($day->format('Y-m-d'));
$sqldate = <<<SQL
SELECT *
FROM `jobdetails`
WHERE datedroppingoff = '$theday' OR datepickingup = '$theday'
SQL;
if(!$resultdate = $db->query($sqldate)){
die('There was an error running the query [' . $db->error . ']');
}
while($rowdate = $resultdate->fetch_assoc()){
echo $rowdate['name'];
}
//
echo '</div>';
}
echo '</div>';
//