《显示时间的JavaScript代码》由会员分享,可在线阅读,更多相关《显示时间的JavaScript代码(2页珍藏版)》请在金锄头文库上搜索。
1、显示年月日,星期,早晚,时钟!-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
2、*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 (星期日,星期一,星期二,星期三,星期四,星期五
3、,星期 六);var monthname =new Array (1 月,2 月,3 月,4 月,5 月,6 月,7 月,8 月,9 月”,”10 月”,”11 月”,”12 月);document.write(+year + 年);document.write(monthnamemonth);document.write(date + 日+);document.write(daynameday+ +);/ January(1月份节日,以下同。)document.write();/-!-document.write();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