代码
- <script language="JavaScript">
- <!--
- calendar = new Date();
- day = calendar.getDay();
- month = calendar.getMonth();
- date = calendar.getDate();
- year = calendar.getYear();
- if (year< 100) year = 1900 + year;
- cent = parseInt(year/100);
- g = year % 19;
- k = parseInt((cent - 17)/25);
- i = (cent - parseInt(cent/4) - parseInt((cent - k)/3) + 19*g + 15) % 30;
- i = i - parseInt(i/28)*(1 - parseInt(i/28)*parseInt(29/(i+1))*parseInt((21-g)/11));
- j = (year + parseInt(year/4) + i + 2 - cent + parseInt(cent/4)) % 7;
- l = i - j;
- emonth = 3 + parseInt((l + 40)/44);
- edate = l + 28 - 31*parseInt((emonth/4));
- emonth--;
- var dayname = new Array ("星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六");
- var monthname =
- new Array ("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月" );
- document.write("<font color=000080>"+year +"年");
- document.write(monthname[month]);
- document.write(date + "日"+" ");
- document.write(dayname[day]+" "+"</font>");
- // January(1月份节日,以下同。)
- if ((month == 0) && (date == 1)) document.write("<br><center><font color=FF0000>今天是<元旦></font>");
- if ((month == 0) && (date == 23)) document.write("<br><center><font color=FF0000>今天是<大年三十></font>");
- if ((month == 0) && (date == 24)) document.write("<br><center><font color=FF0000>今天是<大年初一></font>");
- if ((month == 2) && (date == 8)) document.write("<br><center><font color=FF0000>今天是<三八妇女节></font>");
- if ((month == 4) && (date == 1)) document.write("<br><center><font color=FF0000>今天是<国际劳动节></font>");
- if ((month == 4) && (date == 4)) document.write("<br><center><font color=FF0000>今天是<青年节></font>");
- if ((month == 5) && (date == 1)) document.write("<br><center><font color=FF0000>今天是<国际儿童节></font>");
- if ((month == 6) && (date == 1)) document.write("<br><center><font color=FF0000>今天是<党的生日></font>");
- if ((month == 7) && (date == 1)) document.write("<br><center><font color=FF0000>今天是<建军节></font>");
- if ((month == 11) && (date == 25)) document.write("<br><center><font color=FF0000>今天是<圣诞节></font>");
- document.write("</font>");
- //-->
- </script>
- <script language="JavaScript">
- <!--
- document.write("<span id='clock'></span>");
- var now,hours,minutes,seconds,timeValue;
- function showtime(){
- now = new Date();
- hours = now.getHours();
- minutes = now.getMinutes();
- seconds = now.getSeconds();
- timeValue = (hours >= 12) ? " 下午 " : " 上午 ";
- timeValue += ((hours > 12) ? hours - 12 : hours) + " 点 ";
- timeValue += ((minutes <10)?"0":"") + minutes+" 分 ";
- timeValue += ((seconds <10)?"0":"") + seconds+" 秒 ";
- clock.innerHTML = timeValue;
- setTimeout("showtime()",100);
- }
- showtime();
- //-->
- </script>
本文介绍了一段使用JavaScript实现的日期和时间显示脚本,能够动态获取并展示当前的日期及具体时间,并根据日期判断特定的节日。

被折叠的 条评论
为什么被折叠?



