si si infatti ci ho pensato dopo...
Solo che non riesco a gestire anche giorni mesi e anni di due date...
ho questo:
$secondi = mktime(22,0,0,$mm, $dd, $yyyy);
$secondi2 = mktime(date("G"), date("i"), date("s"), date("m"), date("d"), date("Y"));
$seconds = $secondi - $secondi2;
e passo seconds allo script:
<script>
var seconds = ("<?=$seconds?>");
function $(id) {
return document.getElementById(id);
}
function addOnload(f) {
var prev = window.onload;
window.onload = function() {
if (prev) prev();
f();
}
}
function writecounter(hh, mm, ss) {
$('ore').value = (hh < 10)? "0"+hh : hh;
$('min').value = (mm < 10)? "0"+mm : mm;
$('sec').value = (ss < 10)? "0"+ss : ss;
}
function startcount() {
hh = Math.floor(seconds / 3600);
mm = Math.floor((seconds - (hh*3600)) / 60);
ss = seconds - (hh*3600) - (mm*60);
writecounter(hh, mm, ss);
seconds--;
if (seconds != -1) {
setTimeout('startcount()', 1000)
}
else {
// fai qualcosa
alert("ho finito!");
}
}
var hh = Math.floor(seconds / 3600);
var mm = Math.floor((seconds - (hh*3600)) / 60);
var ss = seconds - (hh*3600) - (mm*60);
addOnload(startcount);
</script>
solo che vorrei anche gestire giorni mesi e anni.. ma non so come fare...