Tengo un archivo php llamado timer.php el cual tiene este codigo:
Código PHP:
   <?
$lectura = fopen("GetTimer", "r");
while(!feof($lectura)) { $lee = fgets($lectura); }
fclose($lectura);
?>
 
<script language="javascript">
    var xx = "<? echo $lee; ?>";
    a = new Date(xx);
    
    function getTime(){
        n = new Date();
        
        r = (a - n);
        rR = Math.floor(r);
        
        l = rR.toString().length;
        m = rR.toString().substr(0,(l - 3));
        
        //p = Math.floor(prova).toString().substr(0,(Math.floor(prova).toString().length-3));
        
        if(m != 0){ document.getElementById('countdown').innerHTML = m; }
        else{
            c = new Date(new Date().getTime() + (7 * 24 * 3600 * 1000));
            
            <?
            $escritura = fopen("GetTimer", "w");
            fputs($escritura,'<script> document.write(c) </script>');
            fclose($escritura);
            ?>
            
            a = c;
        }
        newtime = window.setTimeout("getTime();",1000);
    }
</script>
<body onload="getTime()"><span id="countdown" class="timer"></span></body>    
 

 
 

