HTML显示时间日期

合集下载

万年历(纯HTML语言)

万年历(纯HTML语言)

将其保存为.html格式,即可访问<HTML><HEAD><TITLE>万年历查询</TITLE><METAcontent="农历; 阳历; 月历; 节日; 时区; 节气; 八字; 干支; 生肖; gregorian solar; chinese lunar; calendar;"name=keywords><META content=All name=robots><META content="gregorian solar calendar and chinese lunar calendar"name=description><META http-equiv=Content-Type content="text/html; charset=gb2312"><style type="text/css">p {fONT-FAMIL Y: 宋体; FONT-SIZE: 9pt;line-height:12pt:color:#000000}TD {fONT-FAMIL Y: 宋体,simsun; FONT-SIZE: 9pt}a:link{ color:#000000; text-decoration:none}a:visited{COLOR: #000000; TEXT-DECORA TION: none}a:active{color:green;text-decoration:none}a:hover{color:red;text-decoration:underline}</style><SCRIPT language=JavaScript><!--/*****************************************************************************日期资料*****************************************************************************/ var ttime=0;var tInfo=new Array(0x04bd8,0x04ae0,0x0a570,0x054d5,0x0d260,0x0d950,0x16554,0x056a0,0x09ad0,0x055d2,0x04ae0,0x0a5b6,0x0a4d0,0x0d250,0x1d255,0x0b540,0x0d6a0,0x0ada2,0x095b0,0x14977,0x04970,0x0a4b0,0x0b4b5,0x06a50,0x06d40,0x1ab54,0x02b60,0x09570,0x052f2,0x04970,0x06566,0x0d4a0,0x0ea50,0x06e95,0x05ad0,0x02b60,0x186e3,0x092e0,0x1c8d7,0x0c950,0x0d4a0,0x1d8a6,0x0b550,0x056a0,0x1a5b4,0x025d0,0x092d0,0x0d2b2,0x0a950,0x0b557,0x06ca0,0x0b550,0x15355,0x04da0,0x0a5b0,0x14573,0x052b0,0x0a9a8,0x0e950,0x06aa0,0x0aea6,0x0ab50,0x04b60,0x0aae4,0x0a570,0x05260,0x0f263,0x0d950,0x05b57,0x056a0,0x096d0,0x04dd5,0x04ad0,0x0a4d0,0x0d4d4,0x0d250,0x0d558,0x0b540,0x0b6a0,0x195a6,0x095b0,0x049b0,0x0a974,0x0a4b0,0x0b27a,0x06a50,0x06d40,0x0af46,0x0ab60,0x09570,0x04af5,0x04970,0x064b0,0x074a3,0x0ea50,0x06b58,0x055c0,0x0ab60,0x096d5,0x092e0,0x0c960,0x0d954,0x0d4a0,0x0da50,0x07552,0x056a0,0x0abb7,0x025d0,0x092d0,0x0cab5,0x0a950,0x0b4a0,0x0baa4,0x0ad50,0x055d9,0x04ba0,0x0a5b0,0x15176,0x052b0,0x0a930,0x07954,0x06aa0,0x0ad50,0x05b52,0x04b60,0x0a6e6,0x0a4e0,0x0d260,0x0ea65,0x0d530,0x05aa0,0x076a3,0x096d0,0x04bd7,0x04ad0,0x0a4d0,0x1d0b6,0x0d250,0x0d520,0x0dd45,0x0b5a0,0x056d0,0x055b2,0x049b0,0x0a577,0x0a4b0,0x0aa50,0x1b255,0x06d20,0x0ada0,0x14b63);var solarMonth=new Array(31,28,31,30,31,30,31,31,30,31,30,31);var Gan=new Array("甲","乙","丙","丁","戊","己","庚","辛","壬","癸");var Zhi=new Array("子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥");var Animals=new Array("鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪");var solarTerm = new Array("小寒","大寒","立春","雨水","惊蛰","春分","清明","谷雨","立夏","小满","芒种","夏至","小暑","大暑","立秋","处暑","白露","秋分","寒露","霜降","立冬","小雪","大雪","冬至");var sTermInfo = new Array(0,21208,42467,63836,85337,107014,128867,150921,173149,195551,218072,240693,2633 43,285989,308563,331033,353350,375494,397447,419210,440795,462224,483532,504758);var nStr1 = new Array('日','一','二','三','四','五','六','七','八','九','十');var nStr2 = new Array('初','十','廿','卅','□');var monthName = new Array("一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月");//国历节日*表示放假日var sFtv = new Array("0101*元旦节","0202 世界湿地日","0210 国际气象节","0214 情人节","0301 国际海豹日","0303 全国爱耳日","0305 学雷锋纪念日","0308 妇女节","0312 植树节孙中山逝世纪念日","0314 国际警察日","0315 消费者权益日","0317 中国国医节国际航海日","0321 世界森林日消除种族歧视国际日世界儿歌日", "0322 世界水日","0323 世界气象日","0324 世界防治结核病日","0325 全国中小学生安全教育日","0330 巴勒斯坦国土日","0401 愚人节全国爱国卫生运动月(四月) 税收宣传月(四月)", "0407 世界卫生日","0422 世界地球日","0423 世界图书和版权日","0424 亚非新闻工作者日","0501*劳动节","0504 青年节","0505 碘缺乏病防治日","0508 世界红十字日","0512 国际护士节","0515 国际家庭日","0517 国际电信日","0518 国际博物馆日","0520 全国学生营养日","0523 国际牛奶日","0531 世界无烟日","0601 国际儿童节","0605 世界环境保护日","0606 全国爱眼日","0617 防治荒漠化和干旱日","0623 国际奥林匹克日","0625 全国土地日","0626 国际禁毒日","0701 香港回归纪念日中共诞辰世界建筑日","0702 国际体育记者日","0707 抗日战争纪念日","0711 世界人口日","0730 非洲妇女日","0801 建军节","0808 中国男子节(爸爸节)","0815 抗日战争胜利纪念","0908 国际扫盲日国际新闻工作者日","0909 毛泽东逝世纪念","0910 中国教师节","0914 世界清洁地球日","0916 国际臭氧层保护日","0918 九·一八事变纪念日","0920 国际爱牙日","0927 世界旅游日","0928 孔子诞辰","1001*国庆节世界音乐日国际老人节", "1002*国庆节假日国际和平与民主自由斗争日", "1003*国庆节假日","1004 世界动物日","1006 老人节","1008 全国高血压日世界视觉日","1009 世界邮政日万国邮联日","1010 辛亥革命纪念日世界精神卫生日", "1013 世界保健日国际教师节","1014 世界标准日","1015 国际盲人节(白手杖节)","1016 世界粮食日","1017 世界消除贫困日","1022 世界传统医药日","1024 联合国日","1031 世界勤俭日","1107 十月社会主义革命纪念日","1108 中国记者日","1109 全国消防安全宣传教育日","1110 世界青年节","1111 国际科学与和平周(本日所属的一周)", "1112 孙中山诞辰纪念日","1114 世界糖尿病日","1117 国际大学生节世界学生节","1120*彝族年","1121*彝族年世界问候日世界电视日", "1122*彝族年","1129 国际声援巴勒斯坦人民国际日","1201 世界艾滋病日","1203 世界残疾人日","1205 国际经济和社会发展志愿人员日", "1208 国际儿童电视日","1209 世界足球日","1210 世界人权日","1212 西安事变纪念日","1213 南京大屠杀(1937年)纪念日!谨记血泪史!","1220 澳门回归纪念","1221 国际篮球日","1224 平安夜","1225 圣诞节","1226 毛泽东诞辰纪念")//农历节日*表示放假日var lFtv = new Array("0101*春节","0102*初二","0115 元宵节","0505*端午节","0707 七夕情人节","0715 中元节","0815*中秋节","0909 重阳节","1208 腊八节","1223 小年","0100*除夕")//某月的第几个星期几var wFtv = new Array("0150 世界麻风日", //一月的最后一个星期日(月倒数第一个星期日)"0520 国际母亲节","0530 全国助残日","0630 父亲节","0730 被奴役国家周","0932 国际和平日","0940 国际聋人节世界儿童日","0950 世界海事日","1011 国际住房日","1013 国际减轻自然灾害日(减灾日)","1144 感恩节")/***************************************************************************** 日期计算*****************************************************************************///====================================== 返回农历y年的总天数function lYearDays(y) {var i, sum = 348;for(i=0x8000; i>0x8; i>>=1) sum += (tInfo[y-1900] & i)? 1: 0;return(sum+leapDays(y));}//====================================== 返回农历y年闰月的天数function leapDays(y) {if(leapMonth(y)) return((tInfo[y-1900] & 0x10000)? 30: 29);else return(0);}//====================================== 返回农历y年闰哪个月1-12 , 没闰返回0function leapMonth(y) {return(tInfo[y-1900] & 0xf);}//====================================== 返回农历y年m月的总天数function monthDays(y,m) {return( (tInfo[y-1900] & (0x10000>>m))? 30: 29 );}//====================================== 算出农历, 传入日期控件, 返回农历日期控件// 该控件属性有.year .month .day .isLeap function Lunar(objDate) {var i, leap=0, temp=0;var offset = (Date.UTC(objDate.getFullYear(),objDate.getMonth(),objDate.getDate()) - Date.UTC(1900,0,31))/86400000;for(i=1900; i<2050 && offset>0; i++) { temp=lYearDays(i); offset-=temp; }if(offset<0) { offset+=temp; i--; }this.year = i;leap = leapMonth(i); //闰哪个月this.isLeap = false;for(i=1; i<13 && offset>0; i++) {//闰月if(leap>0 && i==(leap+1) && this.isLeap==false){ --i; this.isLeap = true; temp = leapDays(this.year); }else{ temp = monthDays(this.year, i); }//解除闰月if(this.isLeap==true && i==(leap+1)) this.isLeap = false;offset -= temp;}if(offset==0 && leap>0 && i==leap+1)if(this.isLeap){ this.isLeap = false; }else{ this.isLeap = true; --i; }if(offset<0){ offset += temp; --i; }this.month = i;this.day = offset + 1;}//==============================返回公历y年某m+1月的天数function solarDays(y,m) {if(m==1)return(((y%4 == 0) && (y%100 != 0) || (y%400 == 0))? 29: 28);elsereturn(solarMonth[m]);}//============================== 传入offset 返回干支, 0=甲子function cyclical(num) {return(Gan[num%10]+Zhi[num%12]);}//============================== 阴历属性function calElement(sYear,sMonth,sDay,week,lYear,lMonth,lDay,isLeap,cYear,cMonth,cDay) {this.isToday = false;//瓣句this.sYear = sYear; //公元年4位数字this.sMonth = sMonth; //公元月数字this.sDay = sDay; //公元日数字this.week = week; //星期, 1个中文//农历this.lYear = lYear; //公元年4位数字this.lMonth = lMonth; //农历月数字this.lDay = lDay; //农历日数字this.isLeap = isLeap; //是否为农历闰月?//八字this.cYear = cYear; //年柱, 2个中文this.cMonth = cMonth; //月柱, 2个中文this.cDay = cDay; //日柱, 2个中文this.color = '';this.lunarFestival = ''; //农历节日this.solarFestival = ''; //公历节日this.solarTerms = ''; //节气}//===== 某年的第n个节气为几日(从0小寒起算)function sTerm(y,n) {if(y==2009 && n==2){sTermInfo[n]=43467}var offDate = new Date( ( 31556925974.7*(y-1900) + sTermInfo[n]*60000 ) + Date.UTC(1900,0,6,2,5) );return(offDate.getUTCDate());}//============================== 返回阴历控件(y年,m+1月)/*功能说明: 返回整个月的日期资料控件使用方式: OBJ = new calendar(年,零起算月);OBJ.length 返回当月最大日OBJ.firstWeek 返回当月一日星期由OBJ[日期].属性名称即可取得各项值OBJ[日期].isToday 返回是否为今日true 或false其他OBJ[日期] 属性参见calElement() 中的注解*/function calendar(y,m) {var sDObj, lDObj, lY, lM, lD=1, lL, lX=0, tmp1, tmp2, tmp3;var cY, cM, cD; //年柱,月柱,日柱var lDPOS = new Array(3);var n = 0;var firstLM = 0;sDObj = new Date(y,m,1,0,0,0,0); //当月一日日期this.length = solarDays(y,m); //公历当月天数this.firstWeek = sDObj.getDay(); //公历当月1日星期几////////年柱1900年立春后为庚子年(60进制36)if(m<2) cY=cyclical(y-1900+36-1);else cY=cyclical(y-1900+36);var term2=sTerm(y,2); //立春日期////////月柱1900年1月小寒以前为丙子月(60进制12)var firstNode = sTerm(y,m*2) //返回当月「节」为几日开始cM = cyclical((y-1900)*12+m+12);//当月一日与1900/1/1 相差天数//1900/1/1与1970/1/1 相差25567日, 1900/1/1 日柱为甲戌日(60进制10) var dayCyclical = Date.UTC(y,m,1,0,0,0,0)/86400000+25567+10;for(var i=0;i<this.length;i++) {if(lD>lX) {sDObj = new Date(y,m,i+1); //当月一日日期lDObj = new Lunar(sDObj); //农历lY = lDObj.year; //农历年lM = lDObj.month; //农历月lD = lDObj.day; //农历日lL = lDObj.isLeap; //农历是否闰月lX = lL? leapDays(lY): monthDays(lY,lM); //农历当月最后一天if(n==0) firstLM = lM;lDPOS[n++] = i-lD+1;}//依节气调整二月分的年柱, 以立春为界if(m==1 && (i+1)==term2) cY=cyclical(y-1900+36);//依节气月柱, 以「节」为界if((i+1)==firstNode) cM = cyclical((y-1900)*12+m+13);//日柱cD = cyclical(dayCyclical+i);//sYear,sMonth,sDay,week,//lYear,lMonth,lDay,isLeap,//cYear,cMonth,cDaythis[i] = new calElement(y, m+1, i+1, nStr1[(i+this.firstWeek)%7], lY, lM, lD++, lL,cY ,cM, cD );}//节气tmp1=sTerm(y,m*2 )-1;tmp2=sTerm(y,m*2+1)-1;this[tmp1].solarTerms = solarTerm[m*2];this[tmp2].solarTerms = solarTerm[m*2+1];//guohaoif( y==2009 && m==1){if(tD==3){this[tmp1].solarTerms = ''//this[tmp2].solarTerms = ''}else if(tD==4){this[tmp1].solarTerms = '立春'//this[tmp2].solarTerms = ''}}if(m==3) this[tmp1].color = 'red'; //清明颜色//公历节日for(i in sFtv)if(sFtv[i].match(/^(\d{2})(\d{2})([\s\*])(.+)$/))if(Number(RegExp.$1)==(m+1)) {this[Number(RegExp.$2)-1].solarFestival += RegExp.$4 + ' ';if(RegExp.$3=='*') this[Number(RegExp.$2)-1].color = 'red';}//月周节日for(i in wFtv)if(wFtv[i].match(/^(\d{2})(\d)(\d)([\s\*])(.+)$/))if(Number(RegExp.$1)==(m+1)) {tmp1=Number(RegExp.$2);tmp2=Number(RegExp.$3);if(tmp1<5)this[((this.firstWeek>tmp2)?7:0) + 7*(tmp1-1) + tmp2 - this.firstWeek].solarFestival += RegExp.$5 + ' ';else {tmp1 -= 5;tmp3 = (this.firstWeek+this.length-1)%7; //当月最后一天星期?this[this.length - tmp3 - 7*tmp1 + tmp2 - (tmp2>tmp3?7:0) - 1 ].solarFestival += RegExp.$5 + ' '; }}//农历节日for(i in lFtv)if(lFtv[i].match(/^(\d{2})(.{2})([\s\*])(.+)$/)) {tmp1=Number(RegExp.$1)-firstLM;if(tmp1==-11) tmp1=1;if(tmp1 >=0 && tmp1<n) {tmp2 = lDPOS[tmp1] + Number(RegExp.$2) -1;if( tmp2 >= 0 && tmp2<this.length && this[tmp2].isLeap!=true) {this[tmp2].lunarFestival += RegExp.$4 + ' ';if(RegExp.$3=='*') this[tmp2].color = 'red';}}}//复活节只出现在3或4月if(m==2 || m==3) {var estDay = new easter(y);if(m == estDay.m)this[estDay.d-1].solarFestival = this[estDay.d-1].solarFestival+' 复活节Easter Sunday';}if(m==2) this[20].solarFestival = this[20].solarFestival+unescape('%20%u6D35%u8CE2%u751F%u65E5');//黑色星期五if((this.firstWeek+12)%7==5)this[12].solarFestival += '黑色星期五';//今日if(y==tY && m==tM) this[tD-1].isToday = true;}//======================================= 返回该年的复活节(春分后第一次满月周后的第一主日)function easter(y) {var term2=sTerm(y,5); //取得春分日期var dayTerm2 = new Date(Date.UTC(y,2,term2,0,0,0,0)); //取得春分的公历日期控件(春分一定出现在3月)var lDayTerm2 = new Lunar(dayTerm2); //取得取得春分农历if(lDayTerm2.day<15) //取得下个月圆的相差天数var lMlen= 15-lDayTerm2.day;elsevar lMlen= (lDayTerm2.isLeap? leapDays(y): monthDays(y,lDayTerm2.month)) - lDayTerm2.day + 15;//一天等于1000*60*60*24 = 86400000 毫秒var l15 = new Date(dayTerm2.getTime() + 86400000*lMlen ); //求出第一次月圆为公历几日var dayEaster = new Date(l15.getTime() + 86400000*( 7-l15.getUTCDay() ) ); //求出下个周日this.m = dayEaster.getUTCMonth();this.d = dayEaster.getUTCDate();}//====================== 中文日期function cDay(d){var s;switch (d) {case 10:s = '初十'; break;case 20:s = '二十'; break;break;case 30:s = '三十'; break;break;default :s = nStr2[Math.floor(d/10)];s += nStr1[d%10];}return(s);}///////////////////////////////////////////////////////////////////////////////var cld;function drawCld(SY,SM) {var i,sD,s,size;cld = new calendar(SY,SM);if(SY>1874 && SY<1909) yDisplay = '光绪' + (((SY-1874)==1)?'元':SY-1874);if(SY>1908 && SY<1912) yDisplay = '宣统' + (((SY-1908)==1)?'元':SY-1908);if(SY>1911) yDisplay = '建国' + (((SY-1949)==1)?'元':SY-1949);GZ.innerHTML = yDisplay +'年农历' + cyclical(SY-1900+36) + '年【'+Animals[(SY-4)%12]+'年】';YMBG.innerHTML = "&nbsp;" + SY + "年" + "<BR>&nbsp;" + monthName[SM];for(i=0;i<42;i++) {sObj=eval('SD'+ i);lObj=eval('LD'+ i);sObj.className = '';sD = i - cld.firstWeek;if(sD>-1 && sD<cld.length) { //日期内sObj.innerHTML = sD+1;if(cld[sD].isToday) sObj.className = 'todyaColor'; //今日颜色sObj.style.color = cld[sD].color; //法定假日颜色if(cld[sD].lDay==1) //显示农历月lObj.innerHTML = '<b>'+(cld[sD].isLeap?'闰':'') + cld[sD].lMonth + '月' + (monthDays(cld[sD].lYear,cld[sD].lMonth)==29?'小':'大')+'</b>';else //显示农历日lObj.innerHTML = cDay(cld[sD].lDay);s=cld[sD].lunarFestival;if(s.length>0) { //农历节日if(s.length>6) s = s.substr(0, 4)+'...';s = s.fontcolor('red');}else { //公历节日s=cld[sD].solarFestival;if(s.length>0) {size = (s.charCodeAt(0)>0 && s.charCodeAt(0)<128)?8:4; if(s.length>size+2) s = s.substr(0, size)+'...';s=(s=='黑色星期五')?s.fontcolor('black'):s.fontcolor('blue'); }else { //廿四节气s=cld[sD].solarTerms;if(s.length>0) s = s.fontcolor('limegreen');}}if(cld[sD].solarTerms=='清明') s = '清明节'.fontcolor('red'); if(cld[sD].solarTerms=='芒种') s = '芒种节'.fontcolor('red'); if(cld[sD].solarTerms=='夏至') s = '夏至节'.fontcolor('red'); if(cld[sD].solarTerms=='冬至') s = '冬至节'.fontcolor('red');if(s.length>0) lObj.innerHTML = s;}else { //非日期sObj.innerHTML = '';lObj.innerHTML = '';}}}function changeCld() {var y,m;y=CLD.SY.selectedIndex+1900;m=CLD.SM.selectedIndex;drawCld(y,m);}function pushBtm(K) {switch (K){case 'YU' :if(CLD.SY.selectedIndex>0) CLD.SY.selectedIndex--; break;case 'YD' :if(CLD.SY.selectedIndex<150) CLD.SY.selectedIndex++; break;case 'MU' :if(CLD.SM.selectedIndex>0) {CLD.SM.selectedIndex--;}else {CLD.SM.selectedIndex=11;if(CLD.SY.selectedIndex>0) CLD.SY.selectedIndex--;}break;case 'MD' :if(CLD.SM.selectedIndex<11) {CLD.SM.selectedIndex++;}else {CLD.SM.selectedIndex=0;if(CLD.SY.selectedIndex<150) CLD.SY.selectedIndex++; }break;default :CLD.SY.selectedIndex=tY-1900;CLD.SM.selectedIndex=tM;}changeCld();}var Today = new Date();var tY = Today.getFullYear();var tM = Today.getMonth();var tD = Today.getDate();//////////////////////////////////////////////////////////////////////////////var width = "130";var offsetx = 2;var offsety = 8;var x = 0;var y = 0;var snow = 0;var sw = 0;var cnt = 0;var dStyle;document.onmousemove = mEvn;//显示详细日期资料function mOvr(v) {var s,festival;var sObj=eval('SD'+ v);var d=sObj.innerHTML-1;//sYear,sMonth,sDay,week,//lYear,lMonth,lDay,isLeap,//cYear,cMonth,cDayif(sObj.innerHTML!='') {sObj.style.cursor = 's-resize';if(cld[d].solarTerms == '' && cld[d].solarFestival == '' && cld[d].lunarFestival == '')festival = '';elsefestival = '<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=0 BGCOLOR="#CCFFCC"><TR><TD>'+'<FONT COLOR="#000000" STYLE="font-size:9pt;">'+cld[d].solarTerms + ' ' + cld[d].solarFestival + ' ' + cld[d].lunarFestival+'</FONT></TD>'+'</TR></TABLE>';s= '<TABLE WIDTH="130" BORDER=0 CELLPADDING="2" CELLSPACING=0 BGCOLOR="#000066" style="filter:Alpha(opacity=80)"><TR><TD>' +'<TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD ALIGN="right"><FONT COLOR="#ffffff" STYLE="font-size:9pt;">'+cld[d].sYear+' 年'+cld[d].sMonth+' 月'+cld[d].sDay+' 日<br>星期'+cld[d].week+'<br>'+'<font color="violet">农历'+(cld[d].isLeap?'闰':' ')+cld[d].lMonth+' 月'+cld[d].lDay+' 日</font><br>'+'<font color="yellow">'+cld[d].cYear+'年'+cld[d].cMonth+'月'+cld[d].cDay + '日</font>'+'</FONT></TD></TR></TABLE>'+ festival +'</TD></TR></TABLE>';document.all["detail"].innerHTML = s;if (snow == 0) {dStyle.left = x+offsetx-(width/2);dStyle.top = y+offsety;dStyle.visibility = "visible";snow = 1;}}//清除详细日期资料function mOut() {if ( cnt >= 1 ) { sw = 0; }if ( sw == 0 ) { snow = 0; dStyle.visibility = "hidden";}else cnt++;}//取得位置function mEvn() {x=event.x;y=event.y;if (document.body.scrollLeft){x=event.x+document.body.scrollLeft; y=event.y+document.body.scrollTop;}if (snow){dStyle.left = x+offsetx-(width/2);dStyle.top = y+offsety;}}///////////////////////////////////////////////////////////////////////////function changeTZ() {CITY.innerHTML = CLD.TZ.value.substr(6)setCookie("TZ",CLD.TZ.selectedIndex)}function tick() {var todaytoday = new Date()Clock.innerHTML = today.toLocaleString()Clock2.innerHTML = TimeAdd(today.toGMTString(), CLD.TZ.value)window.setTimeout("tick()", 1000);}function setCookie(name, value) {var today = new Date()var expires = new Date()expires.setTime(today.getTime() + 1000*60*60*24*365)document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() }function getCookie(Name) {var search = Name + "="if(document.cookie.length > 0) {offset = document.cookie.indexOf(search)if(offset != -1) {offset += search.lengthend = document.cookie.indexOf(";", offset)if(end == -1) end = document.cookie.lengthreturn unescape(document.cookie.substring(offset, end))}else return ""}}/////////////////////////////////////////////////////////function initial() {dStyle = detail.style;CLD.SY.selectedIndex=tY-1900;CLD.SM.selectedIndex=tM;drawCld(tY,tM);pushBtm('');CLD.TZ.selectedIndex=getCookie("TZ");changeTZ();tick();}//--></SCRIPT><SCRIPT language=VBScript><!--//===== 算世界时间Function TimeAdd(UTC,T)Dim PlusMinus, DST, y,tSaveIf Left(T,1)="-" Then PlusMinus = -1 Else PlusMinus = 1UTC=Right(UTC,Len(UTC)-5)UTC=Left(UTC,Len(UTC)-4)y = Year(UTC)TimeAdd=DateAdd("n", (Cint(Mid(T,2,2))*60 + Cint(Mid(T,4,2))) * PlusMinus, UTC)//美国日光节约期间: 4月第一个星日00:00 至10月最後一个星期日00:00If Mid(T,6,1)="*" And DateSerial(y,4,(9 - Weekday(DateSerial(y,4,1)) mod 7) ) <= TimeAdd And DateSerial(y,10,31 - Weekday(DateSerial(y,10,31))) >= TimeAdd ThenTimeAdd=CStr(DateAdd("h", 1, TimeAdd)) & "<FONT STYLE='font-size:18pt;font-family:Wingdings; color:red'>R</FONT>"ElseEnd IfTimeAdd = CStr(TimeAdd)End Function--></SCRIPT><STYLE>.todyaColor {BACKGROUND-COLOR: aqua}</STYLE><META content="MSHTML 6.00.2800.1505" name=GENERA TOR></HEAD><BODY leftMargin=0 topMargin=15 onload=initial()><br><SCRIPT language=JavaScript><!--if(navigator.appName == "Netscape" || parseInt(navigator.appVersion) < 4)document.write("<h1>你的浏览器无法执行此程序。

html date用法全解

html date用法全解

html date用法全解
在HTML中,date属性主要用于指定日期,其格式为“YYYY-MM-DD”,即年份-月份-日期。

这个属性可以应用于某些HTML元素,如<input>元素,用于创建日期
选择器。

以下是一个使用date属性的示例:
html
<input type="date" name="birthday" id="birthday">
在这个示例中,<input>元素的type属性被设置为date,这意味着浏览器将显示一个日期选择器,用户可以从日历中选择日期。

name和id属性则用于在表单处理中标识这个输入字段。

需要注意的是,date属性并不是所有浏览器都支持的。

在一些旧版本的浏览器中,可能无法正常显示日期选择器。

因此,在使用date属性时,需要考虑到浏览器的兼容性问题。

此外,Date对象在JavaScript中也扮演了重要角色,主要用于处理时间和日期。

例如,你可以使用Date对象来获取当前时间,创建新的日期,或者对日期进行各种操作,如比较日期、计算日期差、格式化日期等。

总的来说,HTML中的date属性提供了一种方便的方式来在网页中显示和选择日期,而JavaScript中的Date对象则提供了强大的日期和时间处理功能。

最常见的网页显示时间代码

最常见的网页显示时间代码

最常见的网页显示时间代码:将下列代码复制在head标签中即可:<div align="left"><span class="style7">今天是:</span><script language="JavaScript" type="text/javascript"><!--function y2k(number) { return (number < 1000) ? number + 1900 : number; }function dispdate(){var now = new Date();var dd = now.getDate() , mt = now.getMonth() + 1 , yy = y2k(now.getYear()) , weekV al = now.getDay();if (weekV al==0)msg1="星期日";else if (weekV al==1)msg1="星期一";else if (weekV al==2)msg1="星期二";else if (weekV al==3)msg1="星期三";else if (weekV al==4)msg1="星期四";else if (weekV al==5)msg1="星期五";else if (weekV al==6)msg1="星期六";document.write(yy+"年"+mt+"月");document.write('<b><font color=#FFCC00 face="Arial, Helvetica, sans-serif" size="+1">');document.write(dd+"</font></b>日&nbsp;");document.write(msg1);}//--><!--//var version = "other"browserName = navigator.appName;browserVer = parseInt(navigator.appVersion);if (browserName == "Netscape" && browserVer >= 3) version = "n3";else if (browserName == "Netscape" && browserVer < 3) version = "n2";else if (browserName == "Microsoft Internet Explorer" && browserVer >= 4) version = "e4"; else if (browserName == "Microsoft Internet Explorer" && browserVer < 4) version = "e3";function marquee1(){if (version == "e4"){document.write("<marquee style='BOTTOM: 0px; FONT-WEIGHT: 100px; HEIGHT:110px; TEXT-ALIGN: left; TOP: 0px' id='news' scrollamount='1' scrolldelay='10' behavior='loop' direction='up' border='0' onmouseover='this.stop()' onmouseout='this.start()'>") }}function marquee2(){if (version == "e4"){document.write("</marquee>")}}function MM_swapImgRestore() { //v3.0var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;}function MM_swapImage() { //v3.0var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}}//--></script><script language="JavaScript" type="text/javascript">dispdate();</script></SPAN></div>。

在网页中显示日期和时间 - 超级实用的代码收集

在网页中显示日期和时间 - 超级实用的代码收集

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>无标题文档</title></head><body><!--显示日期与时间--><script language="javascript" type="text/javascript">window.onload=function (){setInterval("document.getElementById('time').innerHTML=newDate().toLocaleString()+' 星期'+'日一二三四五六'.charAt(newDate().getDay());",1000);setInterval("document.getElementById('date').innerHTML=newDate().toLocaleDateString()+' 星期'+'日一二三四五六'.charAt(newDate().getDay());",1000);//menuFix();setInterval("document.getElementById('time1').innerHTML=newDate().pattern('yyyy-MM-dd EEE HH:mm:ss');",1000);setInterval("document.getElementById('time2').innerHTML=newDate().format('yyyy-MM-dddddhh:mm:ss TT');",1000);setInterval("document.getElementById('time3').innerHTML=newDate().format('yyyy-MM-ddhh:mm:ss');",1000);}</script><script language="javascript" type="text/javascript"><!--/*** 对Date的扩展,将Date 转化为指定格式的String* 月(M)、日(d)、12小时(h)、24小时(H)、分(m)、秒(s)、周(E)、季度(q) 可以用1-2 个占位符* 年(y)可以用1-4 个占位符,毫秒(S)只能用1 个占位符(是1-3 位的数字) * eg:* (new Date()).pattern("yyyy-MM-ddhh:mm:ss.S") ==> 2006-07-02 08:09:04.423 * (new Date()).pattern("yyyy-MM-dd E HH:mm:ss") ==> 2009-03-10 二20:09:04 * (new Date()).pattern("yyyy-MM-dd EE hh:mm:ss") ==> 2009-03-10 周二08:09:04* (new Date()).pattern("yyyy-MM-dd EEE hh:mm:ss") ==> 2009-03-10 星期二08:09:04* (new Date()).pattern("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18*/Date.prototype.pattern=function(fmt) {var o = {"M+" : this.getMonth()+1, //月份"d+" : this.getDate(), //日"h+" :this.getHours()%12 == 0 ? 12 : this.getHours()%12, //小时"H+" : this.getHours(), //小时"m+" : this.getMinutes(), //分"s+" : this.getSeconds(), //秒"q+" : Math.floor((this.getMonth()+3)/3), //季度"S" : this.getMilliseconds() //毫秒};var week = {"0" : "\u65e5","1" : "\u4e00","2" : "\u4e8c","3" : "\u4e09","4" : "\u56db","5" : "\u4e94","6" : "\u516d"};if(/(y+)/.test(fmt)){fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));}if(/(E+)/.test(fmt)){fmt=fmt.replace(RegExp.$1, ((RegExp.$1.length>1) ? (RegExp.$1.length>2 ? "\u661f\u671f" : "\u5468") : "")+week[this.getDay()+""]);}for(var k in o){if(new RegExp("("+ k +")").test(fmt)){fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+o[k]).substr((""+ o[k]).length)));}}returnfmt;}//var date = new Date();//window.alert(date.pattern("yyyy-MM-ddhh:mm:ss"));// -->//==================================================//这是第二个,是一个老外写的,来源:/akunshenjk/archive/2008/06/12/2539638.aspx/*** 对Date的扩展,将Date 转化为指定格式的String* 月(M)、日(d)、12小时(h)、24小时(H)、分(m)、秒(s)、周(E)、季度(q) 可以用1-2 个占位符* 年(y)可以用1-4 个占位符,毫秒(S)只能用1 个占位符(是1-3 位的数字) * eg:* (new Date()).format("yyyy-MM-ddhh:mm:ss.S") ==> 2006-07-02 08:09:04.423* (new Date()).format("yyyy-MM-ddHH:mm:ss") ==> 2009-03-10 20:09:04* (new Date()).format("yyyy-MM-dddddhh:mm:ss") ==> 2009-03-10 Fri 08:09:04* (new Date()).format("yyyy-MM-dddddhh:mm:ss TT") ==> 2009-03-10 Fri 08:09:04 AM* (new Date()).format("yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18*/Date.prototype.format = function(mask) {var d = this;varzeroize = function (value, length) {if (!length) length = 2;value = String(value);for (var i = 0, zeros = ''; i < (length - value.length); i++) {zeros += '0';}return zeros + value;};returnmask.replace(/"[^"]*"|'[^']*'|\b(?:d{1,4}|m{1,4}|yy(?:yy)?|([hHMstT])\1?|[lLZ])\b/g, function($0) {switch($0) {case 'd': return d.getDate();case 'dd': return zeroize(d.getDate());case 'ddd': return ['Sun','Mon','Tue','Wed','Thr','Fri','Sat'][d.getDay()];case 'dddd': return['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'][d.getDay()] ;case 'M': return d.getMonth() + 1;case 'MM': return zeroize(d.getMonth() + 1);case 'MMM': return['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'][d.getMonth()];case 'MMMM': return['January','February','March','April','May','June','July','August','September','October',' November','December'][d.getMonth()];case 'yy': return String(d.getFullYear()).substr(2);case 'yyyy': return d.getFullYear();case 'h': return d.getHours() % 12 || 12;case 'hh': return zeroize(d.getHours() % 12 || 12);case 'H': return d.getHours();case 'HH': return zeroize(d.getHours());case 'm': return d.getMinutes();case 'mm': return zeroize(d.getMinutes());case 's': return d.getSeconds();case 'ss': return zeroize(d.getSeconds());case 'l': return zeroize(d.getMilliseconds(), 3);case 'L': var m = d.getMilliseconds();if (m > 99) m = Math.round(m / 10);returnzeroize(m);case 'tt': return d.getHours() < 12 ? 'am' : 'pm';case 'TT': return d.getHours() < 12 ? 'AM' : 'PM';case 'Z': return d.toUTCString().match(/[A-Z]+$/);// Return quoted strings with the surrounding quotes removed default: return $0.substr(1, $0.length - 2);}});};</script><div id="date"></div><br><div id="time"></div><div id="time1"></div><div id="time2"></div><div id="time3"></div><!--显示日期与时间end --><br><br></body></html>。

HTML选择浏览器自带日期控件

HTML选择浏览器自带日期控件

HTML选择浏览器自带日期控件
1. 日期(<input type=”date”/>)
这是最基本的日期选择器,你从日历中选择某个日期。

2. 周(<input type=”week”/>)
这时,你选择的就不是一个日期了,而是周。

请注意周数显示的方式。

3. 月份(<input type=”month”/>)
这时你选择的是月份,跟“date”类型比起来少了后面的日子数。

4. 时间(<input type=”time”/>)
这是最简单的一种显示,没有日历,只能选择时间。

5. 日期+时间(<input type=”datetime”/>)
既显示日期组件,又显示时间组件,其实就是“date”类型和“time”类型的组合。

6. 本地日期时间(<input type=”datetime-local”/>)
用本地时间显示。

日历HTML代码(转载)

日历HTML代码(转载)

⽇历HTML代码(转载)1.⽇历HTML 代码:<style type="text/css">#oContainer {width: 193px;padding: 3px;background-color: menu;border-left: buttonhighlight 1px solid;border-top: buttonhighlight 1px solid;border-right: buttonshadow 1px solid;border-bottom: buttonshadow 2px solid;}.DateTable {font: 10pt;word-break: break-all;}.WeekTd, .BlankTd {font: 10pt;border: 1px solid menu;}.Today {font: 10pt;color: red;cursor: hand;position: relative;left: 1px;top: 1px;border-left: 1px solid dimgray;border-top: 1px solid dimgray;border-right: 1px solid white;border-bottom: 1px solid white;}.MonthTd {font: 10pt;font-family: webdings;cursor: hand;border: 1px solid menu;zmm: expression(onmouseenter = function() {style.color = 'red';},onmouseout = function() {style.color = '';});}.SelectTd {border: 1px solid menu;}.over {position: relative;cursor: hand;border-right: 1px solid buttonshadow;border-bottom: 1px solid buttonshadow;border-left: 1px solid buttonhighlight;border-top: 1px solid buttonhighlight;}.out {border-left: 1px solid buttonface;border-top: 1px solid buttonface;border-right: 1px solid buttonface;border-bottom: 1px solid buttonface;}.down {position: relative;left: 1px;top: 1px;border-left: 1px solid dimgray;border-top: 1px solid dimgray;border-right: 1px solid white;border-bottom: 1px solid white;}</style><script language="javascript">var oDate = new Object();function DateClass(_container) {this.author = '-ZMM';this.version = 'Web Calendar 1.0';this.container = _container;this.weekArr = ['⽇', '⼀', '⼆', '三', '四', '五', '六'];this.dateArr = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];this.showTable = function(_year, _month) {this.container.innerHTML = this.getDateTable(_year, _month);}this.getDateTable = function(_year, _month) {if (this.checkArgs(_year, _month)) {_year = parseInt(this.checkDate(_year, _month).split('-')[0]);_month = parseInt(this.checkDate(_year, _month).split('-')[1]);this.Thead = '<table cellpadding="5" cellspacing="0" class="DateTable">\n';this.Thead += '<tr><td align="center" class="MonthTd" onclick="oDate.showTable(' + _year + ', ' + eval(_month-1) + ');">3</td>'; this.Thead += '<td align="center" colspan="5" class="SelectTd"><selectonchange="oDate.showTable(options[selectedIndex].value, ' + _month + ');">';for (var i=1900; i<2101; i++) this.Thead += '<option value="' + i + '" ' + ((_year==i) ? 'selected' : '') + '>' + i + '年</option>';this.Thead += '</select><select onchange="oDate.showTable(' + _year + ', options[selectedIndex].value);">';for (var i=1; i<13; i++) this.Thead += '<option value="' + i + '" ' + ((_month==i) ? 'selected' : '') + '>' + i + '⽉</option>';this.Thead += '</select></td>';this.Thead += '<td align="center" class="MonthTd" onclick="oDate.showTable(' + _year + ', ' + eval(_month+1) + ');">4</td></tr>\n';this.Thead += '<tr>';for (var i=0; i<this.weekArr.length; i++) this.Thead += '<td align="center" class="WeekTd">' + this.weekArr[i] + '</td>';this.Thead += '</tr>\n';this.Tbody = '<tr>';this.dateArr[1] = (!this.checkYear(_year)) ? 28 : 29 ;for (var i=0; i<this.firstPos(_year, _month); i++) this.Tbody += '<td class="BlankTd"></td>';for (var i=1; i<=this.dateArr[_month-1]; i++) {if (this.firstPos(_year, _month) == 0) {if (i!=1 && i%7==1) this.Tbody += '</tr>\n<tr>';} else {if ((i+this.firstPos(_year, _month))%7==1) this.Tbody += '</tr>\n<tr>';}if (!this.today(_year, _month, i)) {this.Tbody += '<td align="center" class="out" onmouseover="className=\'over\';" onmouseout="className=\'out\';" onmousedown="className=\'down\';" onclick="oDate.showDateStr(' + _year + ', ' + _month + ', ' + i + ', \'' + this.weekArr[new Date(_year, _month-1, i).getDay()] + '\');">' + i + '</td>';} else {this.Tbody += '<td align="center" class="Today" onclick="oDate.showDateStr(' + _year + ', ' + _month + ', ' + i + ', \'' + this.weekArr[new Date(_year, _month-1, i).getDay()] + '\');">' + i + '</td>';}}for (var i=0; i<stPos(_year, _month); i++) this.Tbody += '<td class="BlankTd"></td>';this.Tbody += '</tr>\n';this.TFoot = '</table>\n';this.Table = this.Thead + this.Tbody + this.TFoot;return this.Table;} else {return 'Arguments Error!';}}this.firstPos = function(_year, _month) {return new Date(_year, _month-1, 1).getDay();}stPos = function(_year, _month) {return new Date(_year, _month-1, this.dateArr[_month-1]).getDay();}this.checkYear = function(_year) {return ((_year % 4 == 0) && (_year % 100 != 0)) || (_year % 400 == 0);}this.today = function(_year, _month, _date) {return (new Date().getFullYear() == _year) && (new Date().getMonth() == _month-1) && (new Date().getDate() == _date); }this.checkArgs = function(_year, _month) {if (_year<1900 || _year>2100) return false;if (_month<0 || _month>13) return false;return (!isNaN(_year) && !isNaN(_month));}this.checkDate = function(_year, _month) {if (_month<1) {_year --;_month = 12;}if (_month>12) {_year ++;_month = 1;}return _year + '-' + _month;}this.showDateStr = function(_year, _month, _date, _week) {window.alert(_year + '年' + _month + '⽉' + _date + '⽇星期' + _week);}}window.onload = function() {oDate = new DateClass(self.oContainer);oDate.showTable(new Date().getFullYear(), new Date().getMonth()+1);}</script><div id="oContainer"></div>。

HTML网页文件显示时间代码和倒计时代码

HTML网页文件显示时间代码和倒计时代码
date2 = "<font size=5 face=宋体 color=ff0000>" + day + "</font>";
document.write("<center>" + date1.fontsize(2) + date2.fontsize(2) + "</center>");
网页显示时间代码和倒计时代码大全:
<SCRIPT language=JavaScript>
var enabled = 0; today = new Date();
var day; var date;
if(today.getDay()==0) day = "星期日"
var timevalue = "<FONT COLOR=black>" + ((hours >12) ? hours -12 :hours); timevalue += ((minutes < 10) ? "<BLINK>
<FONT COLOR=black>:</FONT></BLINK>0" : "<BLINK><FONT COLOR=black>:</FONT></BLINK>") + minutes+"</FONT></FONT>";
}
timeString = xfile+hours+minutes+seconds;

HTML日期时间插件

HTML日期时间插件

HTML⽇期时间插件Datetime简单全⾯好⽤的⽇期时间插件1.通过id使⽤HTML代码<h3>⽇期时间选择器</h3><input type="text" value="" id="datetimepicker"/><br><br>js代码$('#datetimepicker').datetimepicker({dayOfWeekStart : 1,lang:'en',disabledDates:['1996/01/08','1996/01/09','1996/01/10'],startDate: '1996/01/05'});$('#datetimepicker').datetimepicker({value:'2019/03/24 05:03',step:10});2.通过class使⽤HTML代码<h3>通过Class使⽤</h3><input type="text" class="some_class" value="" id="some_class_1"/></br>js代码$('.some_class').datetimepicker();3.只有时间HTML代码<h3>只有时间</h3><input type="text" id="datetimepicker1"/><br><br></br>js代码$('#datetimepicker1').datetimepicker({datepicker:false,format:'H:i',step:5});4.带有按钮HTML代码<h3>带按钮的</h3><input type="text" value="2016/12/03 18:00" id="datetimepicker4"/><input id="open" type="button" value="open"/><input id="close" type="button" value="close"/><input id="reset" type="button" value="reset"/>js代码$('#datetimepicker4').datetimepicker();$('#open').click(function(){$('#datetimepicker4').datetimepicker('show');});$('#close').click(function(){$('#datetimepicker4').datetimepicker('hide');});$('#reset').click(function(){$('#datetimepicker4').datetimepicker('reset');});5.⿊⾊主题HTML代码<h3>⿊⾊主题</h3><input type="text" id="datetimepicker_dark"/>js代码$('#datetimepicker_dark').datetimepicker({theme:'dark'})$('#datetimepicker_dark').datetimepicker({dayOfWeekStart : 1,lang:'en',disabledDates:['1996/01/08','1996/01/09','1996/01/10'],startDate: '1996/01/05'});$('#datetimepicker_dark').datetimepicker({value:'2019/03/25 05:03',step:1});。

JS在HTML页面显示当前日期

JS在HTML页面显示当前日期

JS在HTML页⾯显⽰当前⽇期代码如下:<!DOCTYPE html><html><head><meta charset="utf-8"/><title></title></head><body><div style="background-color:yellow;"><span><script type="text/javascript">var date = new Date();document.write("今天是:" + date.getFullYear() + "年" + (date.getMonth() + 1) + "⽉" + date.getDate() + "⽇" + " 星期" + "⽇⼀⼆三四五六".charAt(date.getDay()));</script></span></div></body></html>结果显⽰为var date = new Date(); 声明⼀个名称为date的对象,赋值为new Date(); new Date();表⽰创建了⼀个⽇期对象,返回值为当前⽇期。

document.write(); 向输出流(⽂档)写⼊⽂本或HTML。

date.getFullYear() 从Date对象以四位数字返回年份date.getMonth()+1 从Date对象返回⽉份(0-11),返回当前⽉份需+1。

date.getDate() 从Date对象返回⼀个⽉中的某⼀天(1-31)。

stringObject.charAt(index) ⽅法可返回指定位置的字符。

网页显示月份、日期、星期、时间代码

网页显示月份、日期、星期、时间代码

网页显示月份、日期、星期、时间代码一、网页显示月份、日期、星期代码<script language=JavaScript>today=new Date();function initArray(){this.length=initArray.arguments.lengthfor(var i=0;i<this.length;i++)this[i+1]=initArray.arguments[i] }var d=new initArray("星期日","星期一","星期二","星期三","星期四","星期五","星期六");document.write("<font color=##000000 style='font-size:9pt;font-family: 宋体'> ",today.getYear(),"年",today.getMonth()+1,"月",today.getDate(),"日",d[today.getDay()+1],"</font>" );</script>二、六种风格时间显示,一定有你喜欢的!<SCRIPT language="javascript"><!--function initArray(){for(i=0;i<initArray.arguments.length;i++)this[i]=initArray.arguments[i];}var isnMonths=new initArray("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月");var isnDays=new initArray("星期日","星期一","星期二","星期三","星期四","星期五","星期六","星期日");today=new Date();hrs=today.getHours();min=today.getMinutes();sec=today.getSeconds();clckh=""+((hrs>12)?hrs-12:hrs);clckm=((min<10)?"0":"")+min;clcks=((sec<10)?"0":"")+sec;clck=(hrs>=12)?"下午":"上午";var stnr="";var ns="0123456789";var a="";function getFullYear(d){yr=d.getYear();if(yr<1000)yr+=1900;return yr;}document.write("<table>");//下面各行分别是一种风格,把不需要的删掉即可document.write("<TR><TD>风格一:</TD><TD>"+isnDays[today.getDay()]+","+isnMonths[today. getMonth()]+""+today.getDate()+"日,"+getFullYear(today)+"年");document.write("<TR><TD>风格二:</TD><TD>"+clckh+":"+clckm+":"+clcks+""+clck+"</TD></TR>");document.write("<TR><TD>风格三:</TD><TD>"+isnDays[today.getDay()]+","+isnMonths[today. getMonth()]+""+today.getDate()+"日,"+getFullYear(today)+"年"+clckh+":"+clckm+":"+clcks+""+clck+"</TD></TR>");document.write("<TR><TD>风格四:</TD><TD>"+(today.getMonth()+1)+"/"+today.getDate()+"/ "+(getFullYear(today)+"").substring(2,4)+"</TD></TR>");document.write("<TR><TD>风格五:</TD><TD>"+hrs+":"+clckm+":"+clcks+"</TD></TR>");document.write("<TR><TD VALIGN=TOP>风格六:</TD><TD>"+today+"</TD></TR>");document.write("</table>");//--></SCRIPT>三、这个时钟是有影子的,而且还在不停地走着呢<div id="bgclockshade" style="position:absolute;visibility:visible;font-family:'Arialblack';color:#cccccc;font-size:20px;top:50px;left:173px"></div> <div id="bgclocknoshade" style="position:absolute;visibility:visible;font-family:'Arialblack';color:#000000;font-size:20px;top:48px;left:170px"></div> <div id="mainbody" style="position:absolute; visibility:visible"></div><script language=javaScript><!--function www_helpor_net() {thistime= new Date()var hours=thistime.getHours()var minutes=thistime.getMinutes()var seconds=thistime.getSeconds()if (eval(hours) <10) {hours="0"+hours}if (eval(minutes) < 10) {minutes="0"+minutes}if (seconds < 10) {seconds="0"+seconds}thistime = hours+":"+minutes+":"+secondsif(document.all) {bgclocknoshade.innerHTML=thistimebgclockshade.innerHTML=thistime}if(yers) {document.bgclockshade.document.write('<divid="bgclockshade"style="position:absolute;visibility:visible;font-family:Verdana;color:FFAAAAA;font-size:20px;top:10px;left:152px">'+thistime+'</div>')document.bgclocknoshade.document.write('<divid="bgclocknoshade"style="position:absolute;visibility:visible;font-family:Verdana;color:DDDDDD;font-size:20px;top:8px;left:150px">'+thistime+'</div>')document.close()}var timer=setTimeout("www_helpor_net()",200)}www_helpor_net();//--></script>四、数字化的时钟<span id="liveclock" style"=width: 109px; height:15px"></span><SCRIPT language=javascript>function www_helpor_net(){var Digital=new Date()var hours=Digital.getHours()var minutes=Digital.getMinutes()var seconds=Digital.getSeconds()if(minutes<=9)minutes="0"+minutesif(seconds<=9)seconds="0"+secondsmyclock="现在时刻:<font size='5' face='Arial black'>"+hours+":"+minutes+":"+seconds+"</font>"if(yers){yers.liveclock.document.wri te(myclock)yers.liveclock.document.close()}else if(document.all)liveclock.innerHTML=myclocksetTimeout("www_helpor_net()",1000)}www_helpor_net();//--></SCRIPT>五、动态时钟代码2,此代码相当简单<SCRIPT>setInterval("jnkc.innerHTML=newDate().toLocaleString()+' 星期'+'日一二三四五六'.charAt (new Date().getDay());",1000);</SCRIPT>六、flash时钟,改变sz1.swf中的1为0、1、2、3、4、5、6,可以获得不同样式的时钟,你试试吧。

时间日期代码

时间日期代码
var ampm="";
var ampmhour="";
var myweekday="";
var year="";
mydate=new Date();
myweekday=mydate.getDay();
mymonth=mydate.getMonth()+1;
myday= mydate.getDate();
</script>
if(myweekday == 0)
weekday=" 星期日 ";
e=" 星期一 ";
else if(myweekday == 2)
weekday=" 星期二 ";
else if(myweekday == 3)
weekday=" 星期三 ";
else if(myweekday == 4)
weekday=" 星期四 ";
else if(myweekday == 5)
weekday=" 星期五 ";
else if(myweekday == 6)
weekday=" 星期六 ";
document.write(year+"年"+mymonth+"月"+myday+"日 "+weekday+myhour+":"+myminu+":"+mysec+"<br />");

如何在网页中显示日期和跳动的时间

如何在网页中显示日期和跳动的时间
var mName=new Array("1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月");
if (version < 1.3)
{
if (gy<2000)
{
document.write("<FONT COLOR=\"black\" class=\"p1\">"+"19"+y.getYear()+"年" + mName[y.getMonth()] + y.getDate() + "日" + dName[y.getDay()] + "" + "</FONT>");
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds()
var timeValue = "" +((hours >= 12) ? "下午 " : "上午 " )
做完以上的工作,我们在浏览器中就能看到显示日期、星期和动态时间的效果了。
附:显示当前时间代码。如:下午4:00

日历HTML代码(转载)

日历HTML代码(转载)

⽇历HTML代码(转载)1.⽇历HTML 代码:<style type="text/css">#oContainer {width: 193px;padding: 3px;background-color: menu;border-left: buttonhighlight 1px solid;border-top: buttonhighlight 1px solid;border-right: buttonshadow 1px solid;border-bottom: buttonshadow 2px solid;}.DateTable {font: 10pt;word-break: break-all;}.WeekTd, .BlankTd {font: 10pt;border: 1px solid menu;}.Today {font: 10pt;color: red;cursor: hand;position: relative;left: 1px;top: 1px;border-left: 1px solid dimgray;border-top: 1px solid dimgray;border-right: 1px solid white;border-bottom: 1px solid white;}.MonthTd {font: 10pt;font-family: webdings;cursor: hand;border: 1px solid menu;zmm: expression(onmouseenter = function() {style.color = 'red';},onmouseout = function() {style.color = '';});}.SelectTd {border: 1px solid menu;}.over {position: relative;cursor: hand;border-right: 1px solid buttonshadow;border-bottom: 1px solid buttonshadow;border-left: 1px solid buttonhighlight;border-top: 1px solid buttonhighlight;}.out {border-left: 1px solid buttonface;border-top: 1px solid buttonface;border-right: 1px solid buttonface;border-bottom: 1px solid buttonface;}.down {position: relative;left: 1px;top: 1px;border-left: 1px solid dimgray;border-top: 1px solid dimgray;border-right: 1px solid white;border-bottom: 1px solid white;}</style><script language="javascript">var oDate = new Object();function DateClass(_container) {this.author = '-ZMM';this.version = 'Web Calendar 1.0';this.container = _container;this.weekArr = ['⽇', '⼀', '⼆', '三', '四', '五', '六'];this.dateArr = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];this.showTable = function(_year, _month) {this.container.innerHTML = this.getDateTable(_year, _month);}this.getDateTable = function(_year, _month) {if (this.checkArgs(_year, _month)) {_year = parseInt(this.checkDate(_year, _month).split('-')[0]);_month = parseInt(this.checkDate(_year, _month).split('-')[1]);this.Thead = '<table cellpadding="5" cellspacing="0" class="DateTable">\n';this.Thead += '<tr><td align="center" class="MonthTd" onclick="oDate.showTable(' + _year + ', ' + eval(_month-1) + ');">3</td>'; this.Thead += '<td align="center" colspan="5" class="SelectTd"><selectonchange="oDate.showTable(options[selectedIndex].value, ' + _month + ');">';for (var i=1900; i<2101; i++) this.Thead += '<option value="' + i + '" ' + ((_year==i) ? 'selected' : '') + '>' + i + '年</option>';this.Thead += '</select><select onchange="oDate.showTable(' + _year + ', options[selectedIndex].value);">';for (var i=1; i<13; i++) this.Thead += '<option value="' + i + '" ' + ((_month==i) ? 'selected' : '') + '>' + i + '⽉</option>';this.Thead += '</select></td>';this.Thead += '<td align="center" class="MonthTd" onclick="oDate.showTable(' + _year + ', ' + eval(_month+1) + ');">4</td></tr>\n';this.Thead += '<tr>';for (var i=0; i<this.weekArr.length; i++) this.Thead += '<td align="center" class="WeekTd">' + this.weekArr[i] + '</td>';this.Thead += '</tr>\n';this.Tbody = '<tr>';this.dateArr[1] = (!this.checkYear(_year)) ? 28 : 29 ;for (var i=0; i<this.firstPos(_year, _month); i++) this.Tbody += '<td class="BlankTd"></td>';for (var i=1; i<=this.dateArr[_month-1]; i++) {if (this.firstPos(_year, _month) == 0) {if (i!=1 && i%7==1) this.Tbody += '</tr>\n<tr>';} else {if ((i+this.firstPos(_year, _month))%7==1) this.Tbody += '</tr>\n<tr>';}if (!this.today(_year, _month, i)) {this.Tbody += '<td align="center" class="out" onmouseover="className=\'over\';" onmouseout="className=\'out\';" onmousedown="className=\'down\';" onclick="oDate.showDateStr(' + _year + ', ' + _month + ', ' + i + ', \'' + this.weekArr[new Date(_year, _month-1, i).getDay()] + '\');">' + i + '</td>';} else {this.Tbody += '<td align="center" class="Today" onclick="oDate.showDateStr(' + _year + ', ' + _month + ', ' + i + ', \'' + this.weekArr[new Date(_year, _month-1, i).getDay()] + '\');">' + i + '</td>';}}for (var i=0; i<stPos(_year, _month); i++) this.Tbody += '<td class="BlankTd"></td>';this.Tbody += '</tr>\n';this.TFoot = '</table>\n';this.Table = this.Thead + this.Tbody + this.TFoot;return this.Table;} else {return 'Arguments Error!';}}this.firstPos = function(_year, _month) {return new Date(_year, _month-1, 1).getDay();}stPos = function(_year, _month) {return new Date(_year, _month-1, this.dateArr[_month-1]).getDay();}this.checkYear = function(_year) {return ((_year % 4 == 0) && (_year % 100 != 0)) || (_year % 400 == 0);}this.today = function(_year, _month, _date) {return (new Date().getFullYear() == _year) && (new Date().getMonth() == _month-1) && (new Date().getDate() == _date); }this.checkArgs = function(_year, _month) {if (_year<1900 || _year>2100) return false;if (_month<0 || _month>13) return false;return (!isNaN(_year) && !isNaN(_month));}this.checkDate = function(_year, _month) {if (_month<1) {_year --;_month = 12;}if (_month>12) {_year ++;_month = 1;}return _year + '-' + _month;}this.showDateStr = function(_year, _month, _date, _week) {window.alert(_year + '年' + _month + '⽉' + _date + '⽇星期' + _week);}}window.onload = function() {oDate = new DateClass(self.oContainer);oDate.showTable(new Date().getFullYear(), new Date().getMonth()+1);}</script><div id="oContainer"></div>。

HTML5新控件之日期和时间选择输入的实现代码

HTML5新控件之日期和时间选择输入的实现代码

HTML5新控件之⽇期和时间选择输⼊的实现代码HTML5定义了⼏个与⽇期有关的新控件。

⽀持⽇期控件的浏览器会提供⼀个⽅便的下拉式⽇历,供⽤户选择。

注意:⽬前只有Chrome和Opera提供下拉式⽇历⽀持,其它浏览器仍是⼀个普通⽂本框。

1,⽇期控件 - date<input type="date" value="2015-09-24"/>2,时间控件 - time<input type="time" value="13:59"/><input type="time" value="13:59:59"/>3,⽇期时间控件 - datetime-local<input type="datetime-local" value="2015-09-24T13:59:59"/> 4,⽉控件 - month<input type="month" value="2015-09"/>5,周控件 - week<input type="week" value="2015-W02"/>6,⽇期时间控件也⽀持min和max属性,表⽰可设置的最⼩和最⼤时间<input type="date" value="2015-09-24" min="2015-09-16" max="2015-09-26"/>总结以上所述是⼩编给⼤家介绍的HTML5新控件之⽇期和时间选择输⼊,希望对⼤家有所帮助,如果⼤家有任何疑问请给我留⾔,⼩编会及时回复⼤家的。

html上显示动态时间

html上显示动态时间

html页面上显示时间我试了一下,在IE中可以正确显示,显示结果如下:2012年1月30日 16:14:35但是在谷歌的chrome中,就会显示如下效果:Mon Jan 30 2012 16:15:41 GMT+0800 (中国标准时间)我自己整了个笨法,就是方法三,在每个浏览器中显示的效果都和IE相同。

方法一:Html代码1.<body>2.<div id="time"></div>3.4.<script type="text/javascript">5.change();6.function change()7.{8. var today;9.today = new Date();10. timeString = today.toLocaleString();11. document.getElementById("time").innerHTML = timeString;12. setTimeout("change();", 1000);13.}14.</script>15.16.</body>方法二(在onload中调用setInterval):Html代码1.<body onload="setInterval('change()',1000)">2.<div id="time">3.</div>4.5.<script type="text/javascript">6.function change()7.{8. var today;9.today = new Date();10. timeString = today.toLocaleString();11. document.getElementById("time").innerHTML = timeString;12.}13.</script>14.15.</body>方法三:Html代码1.<body onload="show();">2.<div id="nowDiv"></div>3.4.<script type="text/javascript">5.function show(){6. var date = new Date();7. var now = "";8.now = date.getFullYear()+"年";9. if(date.getMonth() <10)10. {11. now now = now +"0";12. }13. now now = now + (date.getMonth()+1)+"月";14. //取月的时候取的是当前月-1如果想取当前月+1就可以了15.16. if(date.getDate() <10)17. {18. now now = now +"0";19. }20. now now = now + date.getDate()+"日 ";21.22. if(date.getHours() <10)23. {24. now now = now +"0";25. }26. now now = now + date.getHours()+":";27.28. if(date.getMinutes() <10)29. {30. now now = now +"0";31. }32. now now = now + date.getMinutes()+":";33.34. if(date.getSeconds() <10)35. {36. now now = now +"0";37. }38. now now = now + date.getSeconds()+" ";39. document.getElementById("nowDiv").innerHTML = now;40. //div的html是now这个字符串41. setTimeout("show()",1000);42. //设置过1000毫秒就是1秒,调用show方法43.}44.45.</script>46.</body>。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
相关文档
最新文档