date - How can I auto populate a dropdown with years going into the future with php -
I have a dropdown that I want to run for 5 years in the future with the date starting from the previous year, but I
Maybe it's easy if I tell that I want to finish with trying to explain.
This year should be hangy
and should have dropdown next year
& lt; Select & gt; & Lt; Options & gt; 2013-08-31 & lt; / Options & gt; & Lt; Options & gt; 2014-08-31 & lt; / Options & gt; & Lt; Options & gt; 2015/08/31 & lt; / Options & gt; & Lt; Options & gt; 2016/08/31 & lt; / Options & gt; & Lt; / Select & gt; And so on
Any ideas got?
You can create a function like this
P>
< Code> function getNextYears ($ to $, $ nbYears) {$ time = strtotime ($ to $); $ Dates = array (); ($ I = 0; $ i & lt; $ nb years; $ i ++) {$ date [] = date ('ym-d', mktem (0, 0, 0, date ('m', $ time ), Date ('d', $ time), date ('y', $ time) + $ i); } Return $ dates; }
Comments
Post a Comment