PHP 실시간 서버 시간 보이기
페이지 정보
본문
<div style="float:left; padding-right:5px;">현재 서버시간 :</div>
<div style="float:left;" id="server_realtime"><?php echo date("Y-m-d H:i:s", time()); ?></div>
<div style="clear:both;"></div>
<script>
var srv_time = "<?php print date("F d, Y H:i:s", time()); ?>";
var now = new Date(srv_time);
setInterval("server_realtime()", 1000);
function server_realtime()
{
now.setSeconds(now.getSeconds()+1);
var year = now.getFullYear();
var month = now.getMonth() + 1;
var date = now.getDate();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
if (month < 10){
month = "0" + month;
}
if (date < 10){
date = "0" + date;
}
if (hours < 10){
hours = "0" + hours;
}
if (minutes < 10){
minutes = "0" + minutes;
}
if (seconds < 10){
seconds = "0" + seconds;
}
document.getElementById("server_realtime").innerHTML = year + "-" + month + "-" + date + " " + hours + ":" + minutes + ":" + seconds;
}
</script>
자료출처
https://ncube.net/12130
<div style="float:left;" id="server_realtime"><?php echo date("Y-m-d H:i:s", time()); ?></div>
<div style="clear:both;"></div>
<script>
var srv_time = "<?php print date("F d, Y H:i:s", time()); ?>";
var now = new Date(srv_time);
setInterval("server_realtime()", 1000);
function server_realtime()
{
now.setSeconds(now.getSeconds()+1);
var year = now.getFullYear();
var month = now.getMonth() + 1;
var date = now.getDate();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
if (month < 10){
month = "0" + month;
}
if (date < 10){
date = "0" + date;
}
if (hours < 10){
hours = "0" + hours;
}
if (minutes < 10){
minutes = "0" + minutes;
}
if (seconds < 10){
seconds = "0" + seconds;
}
document.getElementById("server_realtime").innerHTML = year + "-" + month + "-" + date + " " + hours + ":" + minutes + ":" + seconds;
}
</script>
자료출처
https://ncube.net/12130
댓글목록
등록된 댓글이 없습니다.