Looping through dates


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $start_date = '2008-03-01';
  2. $check_date = $start_date;
  3. $end_date = '2008-03-14';
  4.  
  5. $i = 0;
  6.  
  7. while ($check_date != $end_date) {
  8. $check_date = date ("Y-m-d", strtotime ("+1 day", strtotime($check_date)));
  9. echo $check_date . '<br>';
  10.  
  11. $i++;
  12. if ($i > 31) { die ('Error!'); }
  13. }

URL: http://www.v7n.com/forums/coding-forum/79591-php-loop-through-dates.html

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.