사이트 서버시간을 알수 있는 사이트를 만드는 중입니다 어렵네요 ㅠㅠ
본문
이 사이트 처럼 사이트 유알엘입력하면 서버시간이 나타나는 사이트를 만들려고 하는중인데요
자료를 찾기가 어렵네요
참고가될만한 정보가 있을까요?
답변 2
<!doctype html>
<html lang="ko">
<head>
<title> 서버시간 </title>
</head>
<body>
<div id="server_time"><?php echo date("Y-m-d H:i:s", time()); ?></div>
<script>
var srv_time = "<?php print date("F d, Y H:i:s", time()); ?>";
var now = new Date(srv_time);
setInterval("server_time()", 1000);
function server_time()
{
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_time").innerHTML = year + "-" + month + "-" + date + " " + hours + ":" + minutes + ":" + seconds;
}
</script>
답변을 작성하시기 전에 로그인 해주세요.