Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Date Picker Select Generator for HTML & PHP
<select name="year">
<option value="">Year</option>
<?php for ($year = date('Y'); $year > date('Y')-100; $year--) { ?>
<option value="<?php echo $year; ?>"><?php echo $year; ?></option>
<?php } ?>
<select name="month">
<option value="">Month</option>
<?php for ($month = 1; $month <= 12; $month++) { ?>
<option value="<?php echo strlen($month)==1 ? '0'.$month : $month; ?>"><?php echo strlen($month)==1 ? '0'.$month : $month; ?></option>
<?php } ?>
<select name="day">
<option value="">Day</option>
<?php for ($day = 1; $day <= 31; $day++) { ?>
<option value="<?php echo strlen($day)==1 ? '0'.$day : $day; ?>"><?php echo strlen($day)==1 ? '0'.$day : $day; ?></option>
<?php } ?>

This comment has been minimized.

Copy link

DevJacobZhang commented Apr 24, 2015

hello ! if month:3 day just have 29, how to write ? when user choice month ,day will change.


This comment has been minimized.

Copy link
Owner Author

furkanmustafa commented Apr 26, 2015

@DevJacobZhang, this one was just for a simple input. It's better to use some javascript date picker for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.