JS显示当前年月日时间分秒代码(时间不断变动)
分类:程序开发 Tags: javascript 时间 评论:0 浏览:5426 最近更新时间:2010/3/13 20:44:16
效果如:2010年3月13日 星期六 下午 8点42分30秒
- <script language="JavaScript" type="text/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(year +"年");
- document.write(monthname[month]);
- document.write(date + "日"+" ");
- document.write(dayname[day]);
- //-->
- </script>
- <script language="JavaScript" type="text/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>
本文地址:/466/
-
• 打开网页自动弹出QQ对话框代码
• 支持中文转换的Asp UrlDecode函数
• ASP生成静态页面HTML的方法
• Asp超精准判断客户端操作系统类型代码
• 忽略JS错误代码,网页屏蔽js错误代码
• ASP输出26个英文字母的方法代码
• ASP几种常见分页代码
• 1小时ASP入门,教你简单学会ASP
• asp执行出错,直接忽略错误代码
• asp导出excel文件方法