Skip to content

Instantly share code, notes, and snippets.

@baddot
Forked from furkanmustafa/html-php-date-picker.php
Created February 19, 2018 20:23
Show Gist options
  • Save baddot/4a63f0772e9834c376c22b12e4a664b5 to your computer and use it in GitHub Desktop.
Save baddot/4a63f0772e9834c376c22b12e4a664b5 to your computer and use it in GitHub Desktop.
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>
<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>
<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 } ?>
</select>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment