我需要查看来自2014-06-01'的协议。至今天。我正在努力制作循环。
$today=date('Y-m-d 00:00:00');
$first_day=$my_counter['Counter']['created'];
$pointer = $first_day;
while ($pointer < $today) :
echo $pointer."<br>";
$pointer = $pointer + '24:00:00'; // +86400 or +1d not work
endwhile;
答案 0 :(得分:1)
根据您的要求进行更改尝试
$start = strtotime("2014-07-28 00:00:00");
$today = strtotime(date('Y-m-d'));
while($start != $today) {
echo date('Y-m-d H:i:s', $start);
$start = strtotime('+1 day', $start);
}
输出: - 2014-07-28 00:00:00 2014-07-29 00:00:00
答案 1 :(得分:0)
我认为你正在使用cakephp并且你在'2014-06-01'到$ today之间获取数据。如果是,那么您可以使用此代码。
$start = "2014-06-01";
$results = $this->Counter->find('all', array('conditions' => array("created BETWEEN $start AND NOW() ") ));
foreach($results as $value) {
if( $value['Counter']['age'] != $new_age )
{
echo $value['Counter']['created'];
}
}