<script type="text/javascript">
window.onload = function() {
var timer = parseInt(document.getElementById("timer").innerHTML);
setInterval(function() {
timer++;
document.getElementById("timer").innerHTML = timer;
}, 1000);
}
</script>
<?php
$utente = "pippo";
$file = $utente . ".timer.txt";
if (!file_exists($file)) {
$fr = fopen($file, 'w');
fwrite($fr, time());
fclose($fr);
}
$fr = fopen($file, 'r');
while (!feof($fr)) {
$timer = fgets($fr);
}
fclose($fr);
echo "Il timer è iniziato da <span id='timer'>" . (time() - $timer) . "</span> secondi";