Possible duplicate:How to increase the date from 1 (day / year) in PHP?
Im not quite sure where to start, but I'm trying to start the year in 1928 and stop in 1948 and increase by one per year, since in 2012 these ranges are 1928 - 1948, and in 2013 it will be 1929 - 1949, and 2014 - 1930 - 1950, etc.
right now I have a basic cycle for starting and stopping years, but not too dynamic, as I told them pretty much on the space where to start another date ("Y") + 1.
for($i=1928;$i<=date('Y');$i++) { echo '<option value='.$i.'>'.$i.'</option>'; if($i == '1948'){break;} }
So, do you want it to go between the current year minus 84 and the current year minus 64? Use this code:
$firstYear = (int)date('Y') - 84; $lastYear = $firstYear + 20; for($i=$firstYear;$i<=$lastYear;$i++) { echo '<option value='.$i.'>'.$i.'</option>'; }
: . ( Pitchinnate).
:
$year = date('Y'); $add = $year - 2012; $min = 1928 + $add; $max = $min + 20; for($i=$min;$i<=$max;$i++) { echo '<option value='.$i.'>'.$i.'</option>'; }
( "Y" ) , for, . .
for($i =0; $i <= 20 ;$i++) { $year = date('Y') - 84 + $i; echo '<option value='.$year.'>'.$year.'</option>'; }
, , , , , .
2012 , , 1928 , 2012 , 2012 - 1928 = 84, , , 84 , .
$startingYear = date('Y') - 84; $endingYear = $startingYear + 20; for ($i = $startingYear;$i <= $endingYear;$i++) { echo '<option value='.$i.'>'.$i.'</option>'; }
- ?
$base_year = 2012; $start_year = $base_year - 84; $end_year = $start_year + 20; for( $i = $start_year; $i <= $end_year; $i++) { echo '<option value='.$i.'>'.$i.'</option>'; }