Cod: Selectaţi tot
<?php
//Diferenta in ore dintre timp-ul servarului si timpul pe care doriti sa il afisati
$diferenta_de_ora = "5091.63";
$timeadjust = ($diferenta_de_ora * 60 * 60);
//Calculeaza valorile initiale ale variabilelor de ora/minut/secunda
$timedate_hours = date("H",time()+$timeadjust);
$timedate_mints = date("i",time()+$timeadjust);
$timedate_secon = date("s",time()+$timeadjust);
?>
<head><script language="javascript">
var timerID = null;
var timerRunning = false;
var timeValue;
var timeAM_PM = false; // Daca e true se afiseaza ora in format AM/PM
var now = new Date() ;
//Seteaza valorile luate din PHP pentru ora/minut/secunda
now.setHours('<?php print $timedate_hours; ?>');
now.setMinutes('<?php print $timedate_mints; ?>');
now.setSeconds('<?php print $timedate_secon;?>');
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
function stopclock(){ if(timerRunning); clearTimeout(timerID); timerRunning = false; }
function startclock(){ stopclock(); showtime(); }
function showtime(){
//Daca au trecut 60 de secunde mareste minutele cu 1 si reseteaza secundele, daca nu adauga 1 la secunde
if (seconds == 60) { seconds=0; minutes++; } else {seconds++;}
//Daca au trecut 60 de minute reseteaza minutele si adauga o ora
if (minutes == 60) { minutes=0; hours++; };
//Daca vreti sa afisati cu AM/PM afiseaza ora intre 1 si 12, daca nu intre 1 si 24
if (timeAM_PM) { timeValue = "" + ((hours > 12) ? hours - 12 : hours); }
else { timeValue = "" + (hours); }
timeValue += ((minutes < 10) ? ":0" : ":") + minutes;
timeValue += ((seconds < 10) ? ":0" : ":") + seconds;
//Daca vreti sa afisati AM/PM afisati un sufix la final care sa indice acest lucru
if (timeAM_PM) { timeValue += (hours >= 12) ? " PM" : " AM"; }
//Schimba valoarea la timp.
document.getElementById('timediv').innerHTML = timeValue;
//Executa la fiecare secunda aceasta functie
timerID = setTimeout("showtime()",1000);
timerRunning = true;
}
</script>
</head><body onLoad="startclock()"><div id='timediv';>Asteptati</div></body>
Sper ca va ajuta

