Skip to content

Instantly share code, notes, and snippets.

Created June 21, 2010 10:42
Show Gist options
  • Save anonymous/446695 to your computer and use it in GitHub Desktop.
Save anonymous/446695 to your computer and use it in GitHub Desktop.
<?php
$date = '21/06/2010';
$date_infos = explode('/',$date);
$jour = $date_infos[0];
$mois = $date_infos[1];
$annee = $date_infos[2];
/* Affichage des jours */
echo '<select name="date_jour">';
for($i = 1 ; $i <= 31 ; $i++) {
echo ($i == $jour) ?
'<option value="'.$i.'" selected="selected">'.$i.'</option>'
:
'<option value="'.$i.'">'.$i.'</option>';
}
echo '</select>';
/* Affichage des mois */
echo '<select name="date_mois">';
for($i = 1 ; $i <= 12 ; $i++) {
echo ($i == $mois) ?
'<option value="'.$i.'" selected="selected">'.$i.'</option>'
:
'<option value="'.$i.'">'.$i.'</option>';
}
echo '</select>';
/* Affichage des années */
echo '<select name="date_annee">';
for($i = 1900 ; $i <= (int) date('Y') ; $i++) {
echo ($i == $annee) ?
'<option value="'.$i.'" selected="selected">'.$i.'</option>'
:
'<option value="'.$i.'">'.$i.'</option>';
}
echo '</select>';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment