自己写了个时钟

有需要的拷贝下面代码贴在公告里即可

<script language="javascript">

    window.setInterval("fnRecycle()",1000);

    function fnRecycle(){

        var oDate=new Date();

        var sYear = oDate.getFullYear();

        var sMonth = oDate.getMonth() + 1;

        var sDay = oDate.getDate();

        var sWeekDay = oDate.getDay();

        if(sWeekDay == 6)

        {

            tdDay.style.color = "red";

            tdWeek.style.color = "red";

        }

        else if(sWeekDay == 0)

        {

            tdDay.style.color = "#488E25";

            tdWeek.style.color = "#488E25";

            sWeekDay = 7;

        }

        else if(sWeekDay == 1)

        {

            tdDay.style.color = "gray";

            tdWeek.style.color = "gray";

        }

        else if(sWeekDay == 2)

        {

            tdDay.style.color = "gray";

            tdWeek.style.color = "gray";

        }

        else if(sWeekDay == 3)

        {

            tdDay.style.color = "gray";

            tdWeek.style.color = "gray";

        }

        else if(sWeekDay == 4)

        {

            tdDay.style.color = "gray";

            tdWeek.style.color = "gray";

        }

        else if(sWeekDay == 5)

        {

            tdDay.style.color = "gray";

            tdWeek.style.color = "gray";

        }

        tdWeek.innerHTML = sWeekDay;

        tdDate.innerHTML = sYear + "" + sMonth + "";

        tdDay.innerHTML = sDay;

       

        var sSwitch="上午";

        var iHours=oDate.getHours();

        if(iHours>=12 && iHours<18){

            sSwitch="下午";

        }

        else if(iHours>=0 && iHours<=6)

        {

            sSwitch="凌晨";

        }

        else if(iHours>6 && iHours<12)

        {

            sSwitch="上午";

        }

        else if(iHours>=18 && iHours<=23)

        {

            iHours-=12;

            sSwitch="晚上";

        }

        var sMinutes=oDate.getMinutes() + "";

        if(sMinutes.length==1){

            sMinutes="0" + sMinutes;

        }

        var sSeconds=oDate.getSeconds() + "";

        if(sSeconds.length==1){

            sSeconds="0" + sSeconds;

        }

        tdTime.innerHTML=sSwitch + " " + iHours + ":" + sMinutes + ":" + sSeconds;

    }

</script>

<table style="BORDER-RIGHT: gray 1px dotted; BORDER-TOP: gray 1px dotted; BORDER-LEFT: gray 1px dotted; BORDER-BOTTOM: gray 1px dotted"

                                                    cellSpacing="0" cellPadding="0" width="80%" align="center">

    <tr><td colspan="2">&nbsp;</td></tr>

    <tr>

        <td align="center" style="font-family:Georgia;

    font-size:12px;

    color:Black;" id="tdDate" colspan="2"></td>

    </tr>

    <tr >

        <td align="right" width="60%" style="font-family: Georgia;

    font-weight:bold;

    font-size:28px;

    color:gray;" id="tdDay" valign="top"></td>

        <td align="left" width="40%" style="font-family: Georgia;

    font-size:12px;

    color:Black;" id="tdWeek" valign="top"></td>

    </tr>

    <tr>

        <td align="center" style="font-family: Georgia;

    font-size:12px;

    color:Black;" id="tdTime" colspan="2"></td>

    </tr>

    <tr><td colspan="2">&nbsp;</td></tr>

</table>

<script language="javascript">

    fnRecycle();

</script>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值