cambie la funcion con el strotime.. y sigue sin funcionar...
no entiendo por que me da igual el valor siempre... si las fechas son distintas...
Código PHP:
function cualesmayor($fecha1,$fecha2){
// Formato de entrada d/m/Y H:i:s
// separa hora y fecha
//1
$fecha1 = explode(" ",$fecha1);
$fec1=$fecha1[0];
$hor1=$fecha1[1];
//2
$fecha2 = explode(" ",$fecha2);
$fec2=$fecha2[0];
$hor2=$fecha2[1];
// separar fecha
//1
$fech1=explode("/",$fec1);
$dia1=$fech1[0];
$mes1=$fech1[1];
$ano1=$fech1[2];
//2
$fech2=explode("/",$fec2);
$dia2=$fech2[0];
$mes2=$fech2[1];
$ano2=$fech2[2];
// separar hora
//1
$hors1=explode(":",$hor1);
$hora1=$hors1[0];
$minut1=$hors1[1];
$segun1=$hors1[2];
//2
$hors2=explode(":",$hor2);
$hora2=$hors2[0];
$minut2=$hors2[1];
$segun2=$hors2[2];
/*
// convertimos a timestamp
$fechatime1=mktime ($hora1,$minut1,$segun1,$mes1,$dia1,$ano1);
$fechatime2=mktime ($hora2,$minut2,$segun2,$mes2,$dia2,$ano2);
*/
$fechamy1=$ano1."-".$mes1."-".$dia1." ".$hora1.":".$minut1.":".$segun1;
$fechamy2=$ano2."-".$mes2."-".$dia2." ".$hora2.":".$minut2.":".$segun2;
$fechatime1=strtotime($fechamy1);
$fechatime2=strtotime($fechamy2);
// comparamos cual es mayor, cual menor o si son iguales
if($fechatime1 = $fechatime2){
$result="0";
}
if($fechatime1 > $fechatime2){
$result="1";
}
if($fechatime1 < $fechatime2){
$result="2";
}
// imprimimos el resultado
// devuelve 0 si son iguales, 1 si es mayor la fecha1 y 2 si es mayor la fecha2
//$result=$fechamy1."<br />".$fechamy2;
return $result;
}
asi le llamo:
Código PHP:
<?php $mayor=cualesmayor("02/04/2008 12:33:05","03/04/2008 12:33:06");
echo $mayor;
?>