Ver Mensaje Individual
  #5 (permalink)  
Antiguo 06/02/2008, 18:27
Avatar de eits
eits
 
Fecha de Ingreso: junio-2005
Ubicación: valladolid, yucatán
Mensajes: 1.655
Antigüedad: 19 años, 8 meses
Puntos: 88
Re: problema con fechas

aqui te dejo un ejemplo, con el codigo que pusiste
Código PHP:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
<script language="javascript"> 
function comparar(){
    with(document.forms[0]){
        var auxfec1=Date.parse(an.value+'/'+me.value+'/'+di.value);
        var auxfec2=Date.parse(ano.value+'/'+mes.value+'/'+dia.value);
    }
    if (auxfec1<auxfec2){
        alert('fecha2 mayor que fecha1');
    }
    else if(auxfec1>auxfec2){
        alert('fecha1 mayor que fecha2');
    }
    else{
        alert('fecha1 es igual a fecha2');
    }
}
</script> 
</head>
<body>
<div align="center">
  <table width="630" border="0" class="contact">
    <tr>
      <td width="620"><form action="esp_its3.php" method="post">
          <table width="608" border="0" align="center" cellpadding="0" cellspacing="3">
            <tr>
              <td colspan="3"><div align="left"></div>

              </td>
            </tr>
            
            <tr>
              <td width="134">&nbsp;</td>
              <td width="187">&nbsp;</td>
              <td width="243"><div align="center" class="its">
                  <div align="center">d/m/a</div>
              </div></td>
            </tr>
            <tr>
              <td valign="top" class="formu_txt_1">&nbsp;</td>
              <td valign="top" class="formu_txt_1"><p>Llegada</p></td>
              <td><div align="left"> <?php 

$an
=date("Ye"); 
echo 
"A&ntilde;o:"
echo 
"<select name='an'>"
for(
$i=2008$i<=2011$i++){ 
    echo 
"<option value='".$i."' "
    if(
$an==$i){ 
        echo 
"selected"
    } 
    echo 
">".$i."</option>"

echo 
"</select>"

$me=date("ms"); 
echo 
"Mes:"
echo 
"<select name='me'>"
for(
$i=1$i<=12$i++){ 
    echo 
"<option value='".$i."' "
    if(
$me==$i){ 
        echo 
"selected"
    } 
    echo 
">".$i."</option>"

echo 
"</select>"

echo 
"Dia:"
echo 
"<select name='di'>"
$di=date("da"); 
for(
$i=1$i<=31$i++){ 
    echo 
"<option value='".$i."' "
    if(
$di==$i){ 
        echo 
"selected"
    } 
    echo 
">".$i."</option>"

echo 
"</select>"

?>
              </div></td>
            </tr>
            <tr>
              <td valign="top" class="formu_txt_1">&nbsp;</td>
              <td valign="top" class="formu_txt_1">Salida</td>
              <td><div align="left">
               <?php 
$ano
=date("Y"); 
echo 
"A&ntilde;o:"
echo 
"<select name='ano'>"
for(
$i=2008$i<=2011$i++){ 
    echo 
"<option value='".$i."' "
    if(
$ano==$i){ 
        echo 
"selected"
    } 
    echo 
">".$i."</option>"

echo 
"</select>"

$mes=date("m"); 
echo 
"Mes:"
echo 
"<select name='mes'>"
for(
$i=1$i<=12$i++){ 
    echo 
"<option value='".$i."' "
    if(
$mes==$i){ 
        echo 
"selected"
    } 
    echo 
">".$i."</option>"

echo 
"</select>"

echo 
"Dia:"
echo 
"<select name='dia'>"
$dia=date("d"); 
for(
$i=1$i<=31$i++){ 
    echo 
"<option value='".$i."' "
    if(
$dia==$i){ 
        echo 
"selected"
    } 
    echo 
">".$i."</option>"

echo 
"</select>"


?>
              </div></td>
            </tr>
            <tr>
              <td colspan="3"><hr size='1' color='#D9ECFF' /></td>
            </tr>
          </table>
        <table width="608" border="0">
            <tr>
              <td><hr size='1' color='#D9ECFF' /></td>
            </tr>
            <tr>
              <td><div align="center"><span class="Estilo8">
                  <input name="enviar2" type="button" id="enviar2"  value="Siguiente" onclick="comparar()" />
                  <input name="borrar2" type="reset" id="borrar2" value="Borrar" />
              </span></div></td>
            </tr>
          </table>
      </form></td>
    </tr>
  </table>
  <p>&nbsp;</p>
</div>
</body>
</html>
__________________
El amor es la locura mas lucida que tiene el hombre.- Andres Henestrosa
la tristeza no existe, solo es... la ausencia de la felicidad.

Última edición por eits; 06/02/2008 a las 18:37