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.aiwalls.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>
 
 作者 徐越的專欄

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。