Сообщение от Freedman
|
Подскажите, пожалуйста, что нужно для того, чтобы привести этот таймер в движение
|
Как вариант...
<div id="clock" style="font-size: 42px;"></div>
<a href="?act=logout">Выход</a> / <a href="?act=reset" id='reset'>Обнулить</a>
<script type="text/javascript">
date2 = new Date ();
function clock_update () {
date1 = new Date ();
diff = new Date();
diff.setTime (date1.getTime() - date2.getTime ());
timediff = diff.getTime();
years = Math.floor (timediff / (1000 * 60 * 60 * 24 * 365));
timediff -= years * (1000 * 60 * 60 * 24 * 365);
months = Math.floor (timediff / (1000 * 60 * 60 * 24 * 30));
timediff -= months * (1000 * 60 * 60 * 24 * 30);
weeks = Math.floor (timediff / (1000 * 60 * 60 * 24 * 7));
//timediff -= weeks * (1000 * 60 * 60 * 24 * 7);
days = Math.floor(timediff / (1000 * 60 * 60 * 24));
timediff -= days * (1000 * 60 * 60 * 24);
hours = Math.floor(timediff / (1000 * 60 * 60));
timediff -= hours * (1000 * 60 * 60);
minutes = Math.floor(timediff / (1000 * 60));
timediff -= minutes * (1000 * 60);
seconds = Math.floor(timediff / 1000);
timediff -= seconds * 1000;
if (hours < 10) hours = '0' + hours;
if (minutes < 10) minutes = '0' + minutes;
if (seconds < 10) seconds = '0' + seconds;
document.getElementById ('clock').innerHTML = '';
if (years>0) document.getElementById ('clock').innerHTML += years + 'г. ';
if (months>0) document.getElementById ('clock').innerHTML += months + ' м. ';
if (days>0) document.getElementById ('clock').innerHTML += days + ' д.<br>';
document.getElementById ('clock').innerHTML += hours + ':' + minutes + ':' + seconds + '';
document.getElementById ('reset').href = '?act=resetµtime=' + new Date().getTime();
hours = parseInt (hours);
minutes = parseInt (minutes);
seconds = parseInt (seconds);
}
setInterval ('clock_update ()', 1000);
</script>