js的时间展示

<script type="text/javascript">
$(function() {

//方法调用
    showtime();
    
    //默认加载首页
    $("#nav_menu").find("a")[0].click();
});

   function editCurrentUserPwd() {
        parent.$.modalDialog({
            title : '修改密码',
            width : 600,
            height : 300,
            href : '${pageContext.request.contextPath}/user/editCurrentUserPwdUI.jspx'
        });
    }
    var weekdays = new Array("星期日", "星期一", "星期二","星期三","星期四", "星期五","星期六");
    function showtime(){
        var today=new Date();
        var year = today.getFullYear();
        var month = today.getMonth() + 1;
        var day = today.getDate();
        
        var h=today.getHours();
        var m=checkTime(today.getMinutes());
        var s=checkTime(today.getSeconds());
        
        document.getElementById("timebox").innerHTML = "今天是&nbsp;" + year + "&nbsp;年&nbsp;" + month + "&nbsp;月" + day + "&nbsp;日&nbsp;&nbsp;&nbsp;"
        + weekdays[today.getDay()] + "&nbsp;&nbsp;&nbsp;" + h+":"+m+":"+s;
        setTimeout('showtime()', 500);
    }
     
    function checkTime(i)
    {
        if (i<10)
        {i="0" + i}
        return i
    }
</script>

展示效果

posted @ 2017-09-28 09:22  开文博客园  阅读(529)  评论(0编辑  收藏  举报