0

I need to look up for agreements from '2014-06-01' to $today. I am trying to make loop.

 $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;
tomas3man
  • 29
  • 7

2 Answers2

1

Make changes according to your requirement try

$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);
}

output :- 2014-07-28 00:00:00 2014-07-29 00:00:00

Rakesh Sharma
  • 13,680
  • 5
  • 37
  • 44
0

I thing you are using cakephp and you fetch data between '2014-06-01' to $today. If yes then you can use this code.

$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'];
    }
}   
SohanLal Saini
  • 408
  • 1
  • 3
  • 13