Ver Mensaje Individual
  #13 (permalink)  
Antiguo 05/12/2007, 06:53
Sanubrio
 
Fecha de Ingreso: septiembre-2007
Mensajes: 220
Antigüedad: 19 años
Puntos: 1
Re: A getdate(marca_tiempo) en que formato hay que pasarle la marca de tiempo??

Aunque es mejor y más simple con esas funcione que te dije, si ya lo tienes así:

Código PHP:
function comprobarMiFecha($fecha)
{
    if (!
is_numeric($fecha) || strlen($fecha) != 12)
    {
        return 
false;
    }
    
    return 
true;
}

function 
datosMiFecha($fecha)
{
    if (!
comprobarMiFecha($fecha))
    {
        return 
false;
    }
    
    
$ano    = substr($fecha, 0, 4);
    
$mes    = substr($fecha, 4, 2);
    
$dia    = substr($fecha, 6, 2);
    
$hora   = substr($fecha, 8, 2);
    
$minuto = substr($fecha, 10, 2);
    
    return array(
      
'ano' => $ano,
      
'mes' => $mes,
      
'dia' => $dia,
      
'hora' => $hora,
      
'minuto' => $minuto
    
);
}

function 
convertirMiFechaUnix($fecha)
{
    if (!
comprobarMiFecha($fecha))
    {
        return 
false;
    }
    
    
$datos = datosMiFecha($fecha);
    
    return 
mktime($datos['hora'], $datos['minuto'], 0, $datos['mes'], $datos['dia'], $datos['ano']);
}

$mifecha = 200711221330;

print_r(getdate(convertirMiFechaUnix($mifecha)));