troubleshooting Question

Date increment not working?

Avatar of mhouldridge
mhouldridge asked on
7 Comments1 Solution900 ViewsLast Modified:

I have the following code to increment the dates within a selection box;


$start_date = time() - (720 * 24 * 60 * 60); // today's date
$end_date = strtotime('+2 years'); // Two years from today's date

echo '<select name="dateone"><option>Choose One</option>'."\n";

for ($i = 1, $date = $start_date; $date <= $end_date; $i++) {
      $option_date = date('d-m-Y', $date);
    echo '<option value="'.$option_date.'">'.$option_date.'</option>'."\n";
    $date =  $date + ($i*24*60*60);

echo '</select>';

Problem is, the increment does not work correctly and I cant figure out why?
Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros