현재 서버에 설정된 시간을 디스플레이 합니다. > script

본문 바로가기
사이트 내 전체검색

script

현재 서버에 설정된 시간을 디스플레이 합니다.

페이지 정보

작성자 서방님 댓글 0건 조회 176회 작성일 07-08-11 19:50

본문

서버에 SSI가 사용가능하게 설정되어 있어야 작동합니다. 본 서버에서는 테스트가 불가능합니다.

 

<html>
<head>
    <title>http://www.blueb.co.kr</title>

<script type="text/javascript">
var weekdaystxt=["Sun", "Mon", "Tues", "Wed", "Thurs", "Fri", "Sat"]

function showLocalTime(container, servermode, offsetMinutes, displayversion){
    if (!document.getElementById || !document.getElementById(container)) return
        this.container=document.getElementById(container)
        this.displayversion=displayversion
    var servertimestring=(servermode=="server-php")? '<? print date("F d, Y H:i:s", time())?>' : '<!--#config timefmt="%B %d, %Y %H:%M:%S"--><!--#echo var="DATE_LOCAL" -->'
        this.localtime=this.serverdate=new Date(servertimestring)
        this.localtime.setTime(this.serverdate.getTime()+offsetMinutes*60*1000) //add user offset to server time
        this.updateTime()
        this.updateContainer()
    }
    showLocalTime.prototype.updateTime=function(){
    var thisobj=this
        this.localtime.setSeconds(this.localtime.getSeconds()+1)
    setTimeout(function(){thisobj.updateTime()}, 1000) //update time every second
    }

    showLocalTime.prototype.updateContainer=function(){
    var thisobj=this
    if (this.displayversion=="long")
        this.container.innerHTML=this.localtime.toLocaleString()
    else{
    var hour=this.localtime.getHours()
    var minutes=this.localtime.getMinutes()
    var seconds=this.localtime.getSeconds()
    var ampm=(hour>=12)? "PM" : "AM"
    var dayofweek=weekdaystxt[this.localtime.getDay()]
        this.container.innerHTML=formatField(hour, 1)+":"+formatField(minutes)+":"+formatField(seconds)+" "+ampm+" ("+dayofweek+")"
    }
setTimeout(function(){thisobj.updateContainer()}, 1000) //update container every second
}

function formatField(num, isHour){
    if (typeof isHour!="undefined"){ //if this is the hour field
    var hour=(num>12)? num-12 : num
    return (hour==0)? 12 : hour
    }
    return (num<=9)? "0"+num : num//if this is minute or sec field
}

</script>
</head>
<body onload=showLocalTime()>
현재 서버에 설정된 시간 :<span id="timecontainer"></span>

<script type="text/javascript">
new showLocalTime("timecontainer", "server-ssi", 0, "short")
</script>

댓글목록

등록된 댓글이 없습니다.

회원로그인

접속자집계

오늘
63
어제
302
최대
1,347
전체
155,124
Latest Crypto Fear & Greed Index

그누보드5
Copyright © 서방님.kr All rights reserved.