Ver Mensaje Individual
  #2 (permalink)  
Antiguo 27/07/2008, 00:11
netserver
 
Fecha de Ingreso: mayo-2006
Mensajes: 288
Antigüedad: 18 años
Puntos: 4
Respuesta: script para medicion del tiempo transcurrido

ge ge pues si yo estoy trabajando con ELEARNIGN y pues en algun momento choque con esto.
Te dejo aqui el codigo :

Código PHP:
<?PHP
# DETAILS OF MODULE ################################################
# Modulo: SIMULUC.

#-------------------------------------------------------------------
# Head Vars. ######################################################
    
session_start();
#-------------------------------------------------------------------
#-------------------------------------------------------------------
# Prev. Vars. ######################################################
    
$max_time "123"// Tiempo de duracion expresado en Segundos.
#-------------------------------------------------------------------
#-------------------------------------------------------------------
# Body Functions. ##################################################
    
function timer($timed){
        if(
$timed 10)$timed '0'.$timed;
        return 
$timed;
    }
    function 
time_res($data){
    
$sent $data/3600;
    
$hx split(".",$sent);
    
$sent $data&#37;3600;
    
$sentx $sent/60;
    
$mx explode(".",$sentx);
    
$sx $sent%60;
    
    
$h timer($hx[0]);
    
$m timer($mx[0]);
    
$s timer($sx);
    return 
"Tiempo Restante 0".$h.":".$m.":".$s;
    }
#-------------------------------------------------------------------
#-------------------------------------------------------------------
# Especial Vars. ###################################################
#  SESSION VARS. ###################################################
    
if(empty($_SESSION['time_init'])) $_SESSION['time_init'] = time();
    
$TIME $_SESSION['time_init'];
#  REQUEST VARS. ###################################################
    
$PASO $_GET['p'];
    
$RESP $_POST['r'];
    
$ID $_POST['id'];
    
$AL_ID "al_id"////////////////////////////////////////////////////. 
#  ALGORITMIC VARS. ################################################
    
$TIME_REC time();
    
$RES_TIME $max_time - ($TIME_REC $TIME);
#-------------------------------------------------------------------
if($RES_TIME <= 0)$salida "Tu Tiempo se ha Terminado By PHP";// Aqui se verifica por medio de php si el tiempo indicado ha terminado, si deseas redireccionarlo a otra web te recomiendo que uses etiquetas <META> de redireccion
else $salida time_res($RES_TIME);
?>
<SCRIPT language="javascript">
    var RES_TIME = "<?=$RES_TIME?>";
    function timer(timed){
        if(timed < 10)timed = '0'+timed;
        return timed;
    }
    function time_res(data){
    var h,m,s,sent,hx,mx,nx,sentx,senty;
    sent = ""+data/3600+"";
    hx = sent.split(".");
    sent = data%3600;
    sentx = ""+sent/60+"";
    mx = sentx.split(".");
    sx = ""+sent%60+"";
    
    h = timer(hx[0]);
    m = timer(mx[0]);
    s = timer(sx);
    return "Tiempo Restante "+h+":"+m+":"+s;
    }
    function imprime(segs){
        document.getElementById("php").innerHTML=time_res(segs);
        segs--;
        if(segs >= 0){
            setTimeout("imprime("+segs+")",1000);
        }else{
            document.getElementById("php").innerHTML='Tu Tiempo se ha Terminado By JAVA';// Aqui se verifica por medio de php si el tiempo indicado ha terminado, si deseas redireccionarlo a otra web te recomiendo que uses etiquetas <META> de redireccion.
        }
    }
    setTimeout("imprime(RES_TIME)",1000);
</SCRIPT>
<div id="php" ><?=$salida?></div>
Está basado en php y javascript.

Alguna duda por favor enviemene un Privado.