注册安规 登录
安规网 返回首页

fasten的个人空间 http://bbs.angui.org/?1 [收藏] [复制] [分享] [RSS] www.eychi.com 灼热丝、针焰、漏电起痕、燃烧机、IP淋雨、灯头量规、灯座量规、耐划痕,灯头量规全国市场份额占80%以上

日志

手机或某些浏览器年份代码显示错误的修改办法——112年改为2012

热度 1已有 406 次阅读2012-6-20 10:10 |个人分类:htm代码|系统分类:工作| 2012

正确代码如下:

<script language="JavaScript">

<!--

calendar = new Date();

day = calendar.getDay();

month = calendar.getMonth();

date = calendar.getDate();

year = calendar.getFullYear();

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=000000>"+year +"");

document.write(monthname[month]);

document.write(date + ""+" ");

document.write(dayname[day]+" "+"</font>");

// January(1月份节日,以下同。)

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>

修改过程:getYear改成getFullYear。

以上修改由Hongsen提供建议。


路过

鸡蛋
1

点赞

握手

雷人

刚表态过的朋友 (1 人)

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 注册安规

关闭

安规网为您推荐上一条 /1 下一条

QQ|关于安规|小黑屋|安规QQ群|Archiver|手机版|安规网 ( 粤ICP13023453-10 )

GMT+8, 2024-5-20 22:36 , Processed in 0.072741 second(s), 22 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.|广东安规赞助

返回顶部