Ver Mensaje Individual
  #3 (permalink)  
Antiguo 14/05/2008, 10:03
cmarrero
(Desactivado)
 
Fecha de Ingreso: enero-2008
Ubicación: Mendoza
Mensajes: 458
Antigüedad: 18 años, 8 meses
Puntos: 2
Exclamación Re: Fecha PHP y SQL Server

a ver...

hice lo siguiente: pero no me suma los minutos...

Archivo de funcion:

Código PHP:
function horas($t1, $t2) {

$fecha1 = explode(" ", $t1);
$fecha2 = explode(" ", $t2);

$fecha_inicial = $fecha1[0];
$fecha_final = $fecha2[0];
$s = (strtotime($fecha_final) - strtotime($fecha_inicial)) / 86400;


$tiempo_inicial = explode(":", $fecha1[1]);
$tiempo_final = explode(":", $fecha2[1]);
$hora_final = $tiempo_final[0];
$hora_inicial = $tiempo_inicial[0];


if(
$hora_final >= $hora_inicial) {
$h = $hora_final - $hora_inicial;
} else {
$h = (24 - $hora_inicial) + $hora_final;
$s = $s - 1;
}

$t = 24 * $s + $h;
return 
$t;
} 


Archivo donde muestro y sumo las horas:

Código PHP:
include("control_tiempo.php");
$suma=0;
$t1=0;
$t2=0;
    while (
$row=odbc_fetch_array($date)) {
        
        if (
$row["TYPE"]==1) {
            
$t1=$row["ACCESS_DATE"];
            
        } elseif (
$row["TYPE"]==2) {
        
                if (
$t1!=0) {
                
                    
$t2=$row["ACCESS_DATE"];
                    
$suma+=horas($t1,$t2);
                    
$t1=0;
                }
        }
            
            
    }
echo 
$suma; 

Esto me muestra lo siguiente:
CLAUDIO ADRIAN, MARRERO 10

El tema es que si lo vemos bien, lo unico que me suma son las horas, pero no me tiene en cuenta los minutos y segundos...

COMO MODIFICO ESTO, PARA QUE ME TENGA EN CUENTA LOS MINUTOS Y SEGUNDOS TAMBIEN...

GRACIAS