Year List Select Box

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

Generates an options list of years for a select box, going from current year backwards through the number of years specified in the first variable.

Useful for birthday fields on signup forms.

eg. 2009, 2008, 2007, 2006 ... 1912, 1911, 1910, 1909

EDITED: Now includes option to set the initially selected value to a set number of years ago. Useful if your form is targetted at a certain age group. Will default to current year if set to '0'.

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.