서버시간을 사용한 전자시계 정보
JavaScript 서버시간을 사용한 전자시계본문
<script>
var now = new Date(<?php echo time(); ?>*1000);
Number.prototype.zf = function(){return (this > 9 ? '' : '0') + this;};
function startTime() {
now.setSeconds(now.getSeconds() + 1);
var h = now.getHours().zf(), m = now.getMinutes().zf(), s = now.getSeconds().zf();
document.getElementById('time').innerHTML = h + ':' + m + ':' + s;
setTimeout('startTime()',1000);
}
</script>
<body onload="startTime()">
<div id="time"></div>
추천
2
2
댓글 2개
앗 감사합니다! 복받으세요 (__)
감사합니다. 밀리세컨드까지 일치하게 가져오는 방법도 있을까요?