Javascript-форум (https://javascript.ru/forum/)
-   Общие вопросы Javascript (https://javascript.ru/forum/misc/)
-   -   как заставить работать часы (https://javascript.ru/forum/misc/19457-kak-zastavit-rabotat-chasy.html)

d4a1 04.08.2011 20:56

как заставить работать часы
 
Добрый вечер.
Вот кусок кода, где выводится Время.
<p class="time">
                                                
                                                    <span class="day">{$detail[$team['id']]['left_day']}</span> д., 
                                                
                                                <span class="hours">{$detail[$team['id']]['left_hour']}</span>:
                                                <span class="minutes">{$detail[$team['id']]['left_minute']}</span>:
                                                <span class="secundes">{$detail[$team['id']]['left_time']}</span>

                                            </p>


Работает когда обновляю страницу. Подскажите пожалуйста, как сделать автоматически. :)

Magneto 04.08.2011 21:23

<!doctype html>
<html><head>
	<title>Simple Clock</title>
		<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<style type="text/css">
*{
	padding:0;
	margin:0}
body{
	width:170px;
	height:44px;
	font:38px/44px Consolas;
	text-align:right;
	color:#aaa;
	text-shadow:0px 0px 1px #777;
	background:#000}
</style>
</head><body id="body">
<script type="text/javascript">

function getTime()
	{
		var tT = new Date();
		var sS = tT.getSeconds();
			sS = sS == 0 ? '00' : sS < 10 ? '0' + sS : sS;
		var mM = tT.getMinutes();
			mM = mM == 0 ? '00' : mM < 10 ? '0' + mM : mM;
		var hH = tT.getHours();
		
		var tC = hH + ':' + mM + ':' + sS;
		
		document.getElementById('body').innerHTML = tC;
	}

getTime();
setInterval('getTime()', 1000);

</script>
</body></html>

d4a1 04.08.2011 21:29

Magneto, Благодарю.
А как мне это к своему куску кода привязать ?
Подскажи пожалуйста. У меня опыта нехватает


Часовой пояс GMT +3, время: 00:44.