Ver Mensaje Individual
  #8 (permalink)  
Antiguo 16/12/2008, 14:38
Avatar de Triby
Triby
Mod on free time
 
Fecha de Ingreso: agosto-2008
Ubicación: $MX->Gto['León'];
Mensajes: 10.106
Antigüedad: 16 años, 7 meses
Puntos: 2237
Respuesta: convertir de texto a horas.

Código PHP:
// Convertimos fecha y hora en timestamps
$inicial strtotime("$fecha $hora_ini");
$final strtotime("$fecha $hora_ter");
// Si la hora final es menor que la inicial entonces debe agregarse 1 dia
if($final $inicial
    
$final += 86400;
$total_horas $final $inicial;
$fecha_final $final
Ups, creo que hora_ter se refiere al total de horas y de ahi hacer el calculo de la hora final.

Código PHP:
// Convertimos fecha y hora en timestamps
 // Creamos la fecha inicial con su hora correspondiente
$inicial strtotime("$fecha $hora_ini");

// Obtenemos hora y minutos en base a la hora final hh:mm
list($hr,$min) = explode(':'$hora_ter);

// Convertimos la hora final en segundos
$agregar = ($hr 3600) + ($min 60);

// Obtenemos la fecha final agregando las horas transcurridas
// de esta forma, la fecha tambien se actualiza
$fecha_final $inicial $agregar;

// Ahora puedes obtener la fecha y hora final
list($dia$mes$anio$hr$min) = explode('-'date('d-m-y-G-i'$fecha_final));
$hora_final "$hr:$min"
__________________
- León, Guanajuato
- GV-Foto

Última edición por Triby; 17/12/2008 a las 14:42