Created
July 10, 2013 12:27
-
-
Save jartes/5965877 to your computer and use it in GitHub Desktop.
Formulario fecha de nacimiento
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<select name="dia" id="dia"> | |
<option value=""></option> | |
<?php | |
$i = 1; | |
while ( $i <= 31 ) { | |
if ( $i < 10 ) { | |
$dia = '0' . $i; | |
} | |
else { | |
$dia = $i; | |
} | |
echo "<option value='$dia'>$dia</option>"; | |
$i++; | |
} | |
?> | |
</select> | |
<select name="mes" id="mes"> | |
<option value=""></option> | |
<?php | |
$meses = array( | |
'01' => 'Enero', | |
'02' => 'Febrero', | |
'03' => 'Marzo', | |
'04' => 'Abril', | |
'05' => 'Mayo', | |
'06' => 'Junio', | |
'07' => 'Julio', | |
'08' => 'Agosto', | |
'09' => 'Septiembre', | |
'10' => 'Octubre', | |
'11' => 'Noviembre', | |
'12' => 'Diciembre' | |
); | |
foreach ($meses as $num_mes => $mes) { | |
echo "<option value='$num_mes'>$mes</option>"; | |
} | |
?> | |
</select> | |
<select name="anyo" id="anyo"> | |
<option value=""></option> | |
<?php | |
$tope = date( 'Y' ); | |
$e_max = 75; | |
$e_min = 14; | |
$anyo = $tope - $e_min; | |
while ( $anyo >= ( $tope - $e_max )) { | |
echo "<option value='$anyo'>$anyo</option>"; | |
--$anyo; | |
} | |
?> | |
</select> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment