I currently found this date function a while back that works fine ( can't remember where i found it) but it displays all days, months and years from 2013. The problem is now I need people to be able to select 2014 from the drop down as well. Not really sure what I should edit to add this.
Thanks for any help... the code:
function date_dropdown($year_limit = 0){
$daynow = date("d");
$monthnowtxt = date('F');
$monthnow = date('m');
$yearnow = date("20y");
$html_output = '<div id="date_select" >'."
";
$html_output .= '<label for="date_day">Date of Longplay</label>'."
";
/*days*/
$html_output .= '<select name="date_day" id="day_select"><option ="selected" value="' . $daynow . '">' . $daynow . '</option>'."
";
for ($day = 1; $day <= 31; $day++) {
$html_output .= '<option>' . $day . '</option>'."
";
}
$html_output .= '</select>'."
";
/*months*/
$html_output .= '<select name="date_month" id="month_select" ><option selected="selected" value="' . $monthnow . '">' . $monthnowtxt . '</option>'."
";
$months = array("", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
for ($month = 1; $month <= 12; $month++) {
$html_output .= ' <option value="' . $month . '">' . $months[$month] . '</option>'."
";
}
$html_output .= '</select>'."
";
/*years*/
$html_output .= '<select name="date_year" id="year_select"><option ="selected" value="' . $yearnow . '">' . $yearnow . '</option>'."
";
for ($year = 1900; $year <= (date("Y") - $year_limit); $year++) {
$html_output .= ' <option>' . $year . '</option>'."
";
}
$html_output .= '</select>'."
";
$html_output .= '</div>'."
";
return $html_output;
}
This is the bit you need to change
for ($year = 1900; $year <= (date("Y") - $year_limit); $year++)
date('Y')
will return 2013
date('Y')+1
will return 2014
for ($year = 1900; $year <= ((date("Y")+1) - $year_limit); $year++)
I have to say I don't like the function you included and there are probably cleaner more flexible ways to do what it does.
this method call gives you 2014:
date_dropdown(-1);
change this
for ($year = 1900; $year <= (date("Y") - $year_limit); $year++)
to this
for ($year = 1900; $year <= ((date("Y")+1) - $year_limit); $year++)
Change your for
loop
for ($year = 1900; $year <= (date("Y") - $year_limit); $year++)
to
for ($year = 1900; $year <= $year_limit); $year++)
and pass an argument something greater than 2014...