当前位置:编程学习 > JAVA >>

JavaScript的Date对象(一)

<head>
    <title></title>
    <script type="text/javascript">
        function ReNewTime() {
            var MyDate = new Date();
            var year = MyDate.getYear();                                                     // 年
            var month = MyDate.getMonth() + 1;                                        // 月份是从0—11计算所以要加1
            var date = MyDate.getDate();                                                   // 日
            var day = MyDate.getDay();                                                      // 星期几www.zzzyk.com
            var hour = MyDate.getHours();                                                 // 时
            var minute = MyDate.getMinutes();                                          // 分钟
            var second = MyDate.getSeconds();                                       // 秒
            return(year + "年" + month + "月" + date + "日" + "  星期" + day + "    " + hour + "
 
                   时" + minute + "分" + second + "秒");
        }
 
        function showtime() {
            alert(ReNewTime());
            setTimeout(showtime, 1000);          
        }
 
        showtime();
    </script>
</head>
 
 作者 徐越的专栏
补充:web前端 , JavaScript ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,