日期时间带星期农历js代码特效

合集下载

带农历的日期代码

带农历的日期代码
if ((yyyy > 1901) && (CnDateofDate(new Date((yyyy - 1)+"/12/31")) < 0)){
ResultMonth = - CnMonth[0];}
else {ResultMonth = CnMonth[0];}
ResultDay = CnBeginDay + DaysCount;
var Dizhi=new Array("子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥");
return Tiangan[YYYY%10]+Dizhi[YYYY%12];
}
function CnDateofDateStr(DateGL){
if(CnMonthofDate(DateGL)=="零月") return "请调整您的计算机日期!";
0x87,0x6a,0x57,0x04,0x12,0x75,0x2b,0x00,0x1d,0xb6,0x95,0x00,0x8a,0xad,0x55,0x02,
0x15,0x55,0xaa,0x00,0x82,0x55,0x6c,0x07,0x0d,0xc9,0x76,0x00,0x17,0x64,0xb7,0x00,
CnDaysCount+= CnMonthDays[I];
I++;
}

JavaScript+jQuery网页特效设计任务驱动教程 单元2 设计日期时间类网页特效

JavaScript+jQuery网页特效设计任务驱动教程 单元2  设计日期时间类网页特效

表2-3 以自定义形式显示当前日期及星期数的JavaScript程序之二
序号 01 02 03 04 05 06 07 08 09 10 11
程序 代码 <span id="showtime" > <script>
var year=""; mydate=new Date(); mymonth=mydate.getMonth()+1; myday= mydate.getDate(); myyear= mydate.getFullYear(); showtime.innerHTML=myyear+"年"+mymonth+"月"+myday+"日 星期"
10
document.write(year+"年"+isMonth[today.getMonth()]+day+"日 "
11
+isDay[today.getDay()]) ;
12
//-->
13
</script>
2.1 JavaScript的运算符与表达式
运算符也称为操作符,JavaScript常用的运算符有:算术运 算符(包括+、-、*、/、%、++、--)、比较运算符(包括<、 <=、>、>=、==、!=)、逻辑运算符(&&、||、!)、赋值运 算符(=)、条件运算符(? :)以及其他类型的运算符。
else { // 当条件为false时执行的代码 }
3.if…else if…else…语句

js获取本日、本周、本月的时间代码

js获取本日、本周、本月的时间代码

js获取本⽇、本周、本⽉的时间代码本⽇时间function showToDay(){var Nowdate=new Date();M=Number(Nowdate.getMonth())+1alert(Nowdate.getMonth()+"⽉,"+Nowdate.getDate()+"号,星期"+Nowdate.getDay());return Nowdate.getYear()+"-"+M+"-"+Nowdate.getDate();}昨天function showTomorrow(){var tom=new Date();tom.setDate(tom.getDate()+1);M=Number(tom.getMonth())+1return tom.getYear()+"-"+M+"-"+tom.getDate();}本周第⼀天function showWeekFirstDay(){var Nowdate=new Date();var WeekFirstDay=new Date(Nowdate-(Nowdate.getDay()-1)*86400000);M=Number(WeekFirstDay.getMonth())+1return WeekFirstDay.getYear()+"-"+M+"-"+WeekFirstDay.getDate();}本周最后天function showWeekLastDay(){var Nowdate=new Date();var WeekFirstDay=new Date(Nowdate-(Nowdate.getDay()-1)*86400000);var WeekLastDay=new Date((WeekFirstDay/1000+6*86400)*1000);M=Number(WeekLastDay.getMonth())+1return WeekLastDay.getYear()+"-"+M+"-"+WeekLastDay.getDate();}本⽉第⼀天function showMonthFirstDay(){var Nowdate=new Date();var MonthFirstDay=new Date(Nowdate.getYear(),Nowdate.getMonth(),1);M=Number(MonthFirstDay.getMonth())+1return MonthFirstDay.getYear()+"-"+M+"-"+MonthFirstDay.getDate();}本⽉最后⼀天function showMonthLastDay(){var Nowdate=new Date();var MonthNextFirstDay=new Date(Nowdate.getYear(),Nowdate.getMonth()+1,1);var MonthLastDay=new Date(MonthNextFirstDay-86400000);M=Number(MonthLastDay.getMonth())+1return MonthLastDay.getYear()+"-"+M+"-"+MonthLastDay.getDate();}function getTime(s){var time1=document.getElementById("num1");var time2=document.getElementById("num2");if(s==1){//本⽇时间time1.value=showToDay();//alert("今⽇:"+time1.value);time2.value=showTomorrow();//alert("今⽇:"+time2.value);}else if(s==2){//本周时间time1.value=showWeekFirstDay();//alert("本⽉第⼀天:"+time1.value);time2.value=showWeekLastDay();//alert("本⽉最后⼀天:"+time2.value);}else{//本⽉时间time1.value=showMonthFirstDay();//alert("本⽉第⼀天"+time1.value);time2.value=showMonthLastDay();//alert("本⽉最后⼀天"+time2.value);}}其他⽹友补充的完整测试代码<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Document</title></head><body><input type="text" id="dateFrom" value=""><input type="text" id="dateTo" value=""><script>window.onload = function() {// getDate("thisDay");// getDate("thisWeek");// getDate("thisMonth");getDate("thisYear");}//获取推送时间段function getDate(type){var kssj,jssj;var today = new Date();var DAY = 1000*60*60*24;if(type =="thisDay") { //当天kssj = new Date();jssj = new Date();}if(type == "thisWeek") { //本周周kssj = getThisWeekFirstDay();//本周第⼀天jssj = new Date();}if(type == "thisMonth") { //本⽉kssj = getThisMonthFirstDay();//本⽉第⼀天jssj = new Date();}if(type == "thisYear") {kssj = getThisYearFirstDay();//本年第⼀天jssj = new Date();}var dateFrom = kssj.format('yyyy-MM-dd');var dateTo = jssj.format('yyyy-MM-dd');document.getElementById("dateFrom").value=dateFrom;document.getElementById("dateTo").value=dateTo;}function getThisWeekFirstDay() {var now = new Date();var day = now.getDay();var week = "1234567";var first = 0 - week.indexOf(day);var thisWeekfirstDay = new Date;thisWeekfirstDay.setDate (thisWeekfirstDay.getDate () + first); return thisWeekfirstDay;}function getThisMonthFirstDay(){var date=new Date();date.setDate(1);return date;}function getThisYearFirstDay() {var currentDate=new Date();var currentYear=currentDate.getFullYear();var currentYearFirstDate=new Date(currentYear,0,1);return currentYearFirstDate;}//data类型转stringDate.prototype.format = function(format){var o = {"M+" : this.getMonth()+1, //month"d+" : this.getDate(), //day"h+" : this.getHours(), //hour"m+" : this.getMinutes(), //minute"s+" : this.getSeconds(), //second"q+" : Math.floor((this.getMonth()+3)/3), //quarter"S" : this.getMilliseconds() //millisecond}if(/(y+)/.test(format)) format=format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length)); for(var k in o)if(new RegExp("("+ k +")").test(format)) format = format.replace(RegExp.$1,RegExp.$1.length==1 ? o[k] :("00"+ o[k]).substr((""+ o[k]).length));return format;}</script></body></html>这样基本上就解决问题了。

js显示时间+农历+节日

js显示时间+农历+节日

195551,218072,240693,263343,285989,308563,331033,353350,375494,397447,419210,
0x04970,0x0a4b0,0x0b4b5,0x06a50,0x06d40,0x1ab54,0x02b60,0x09570,0x052f2,0x04970,
0x06566,0x0d4a0,0x0ea50,0x06e95,0x05ad0,0x02b60,0x186e3,0x092e0,0x1c8d7,0x0c950,
}
if(offset==0 && leap>0 && i==leap+1)
if(this.isLeap)
{ this.isLeap = false; }
else
{ this.isLeap = true; --i; --this.monCyl;}
return(cl+SY+'年'+(SM+1)+'月'+SD+'日</font>');
}
function weekday(){
var day = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
var cl = '<font color="#000000" STYLE="font-size:9pt;">';
if(leap>0 && i==(leap+1) && this.isLeap==false)

获取阴历(农历)和当前日期的js代码

获取阴历(农历)和当前日期的js代码

获取阴历(农历)和当前⽇期的js代码本⽂为⼤家分享了⼀段js显⽰阴历(农历)和当前⽇期的关键性代码,供⼤家参考,具体内容如下var CalendarData=new Array(100);var madd=new Array(12);var tgString="甲⼄丙丁戊⼰庚⾟壬癸";var dzString="⼦丑寅卯⾠巳午未申⾣戌亥";var numString="⼀⼆三四五六七⼋九⼗";var monString="正⼆三四五六七⼋九⼗冬腊";var weekString="⽇⼀⼆三四五六";var sx="⿏⽜虎兔龙蛇马⽺猴鸡狗猪";var cYear,cMonth,cDay,TheDate;CalendarData = new Array(0xA4B,0x5164B,0x6A5,0x6D4,0x415B5,0x2B6,0x957,0x2092F,0x497,0x60C96,0xD4A,0xEA5,0x50DA9,0x5AD,0x2B6,0x3126E, 0x92E,0x7192D,0xC95,0xD4A,0x61B4A,0xB55,0x56A,0x4155B, 0x25D,0x92D,0x2192B,0xA95,0x7169 madd[0]=0;madd[1]=31;madd[2]=59;madd[3]=90;madd[4]=120;madd[5]=151;madd[6]=181;madd[7]=212;madd[8]=243;madd[9]=273;madd[10]=304;madd[11]=334;function GetBit(m,n){return (m>>n)&1;}function e2c(){TheDate= (arguments.length!=3) ? new Date() : new Date(arguments[0],arguments[1],arguments[2]);var total,m,n,k;var isEnd=false;var tmp=TheDate.getYear();if(tmp<1900){tmp+=1900;}total=(tmp-1921)*365+Math.floor((tmp-1921)/4)+madd[TheDate.getMonth()]+TheDate.getDate()-38;if(TheDate.getYear()%4==0&&TheDate.getMonth()>1) {total++;}for(m=0;;m++){k=(CalendarData[m]<0xfff)?11:12;for(n=k;n>=0;n--){if(total<=29+GetBit(CalendarData[m],n)){isEnd=true; break;}total=total-29-GetBit(CalendarData[m],n);}if(isEnd) break;}cYear=1921 + m;cMonth=k-n+1;cDay=total;if(k==12){if(cMonth==Math.floor(CalendarData[m]/0x10000)+1){cMonth=1-cMonth;}if(cMonth>Math.floor(CalendarData[m]/0x10000)+1){cMonth--;}}}function GetcDateString(){var tmp="";tmp+=tgString.charAt((cYear-4)%10);tmp+=dzString.charAt((cYear-4)%12);tmp+="(";tmp+=sx.charAt((cYear-4)%12);tmp+=")年 ";if(cMonth<1){tmp+="(闰)";tmp+=monString.charAt(-cMonth-1);}else{tmp+=monString.charAt(cMonth-1);}tmp+="⽉";tmp+=(cDay<11)?"初":((cDay<20)?"⼗":((cDay<30)?"廿":"三⼗"));if (cDay%10!=0||cDay==10){tmp+=numString.charAt((cDay-1)%10);}return tmp;}function GetLunarDay(solarYear,solarMonth,solarDay){//solarYear = solarYear<1900?(1900+solarYear):solarYear;if(solarYear<1921 || solarYear>2020){return "";}else{solarMonth = (parseInt(solarMonth)>0) ? (solarMonth-1) : 11;e2c(solarYear,solarMonth,solarDay);return GetcDateString();}}var D=new Date();var yy=D.getFullYear();var mm=D.getMonth()+1;var dd=D.getDate();var ww=D.getDay();var ss=parseInt(D.getTime() / 1000);if (yy<100) yy="19"+yy;function showCal(){document.write(GetLunarDay(yy,mm,dd));}页⾯调⽤代码:<script language="JavaScript" type="text/javascript" src="getCNdate.js"></script><script type="text/javascript">showCal();</script>代码⼆:⽤JavaScript获取当前农历⽇期<script type="text/javascript">var sWeek = new Array("星期⽇","星期⼀","星期⼆","星期三","星期四","星期五","星期六");var dNow = new Date();var CalendarData=new Array(100);var madd=new Array(12);var tgString="甲⼄丙丁戊⼰庚⾟壬癸";var dzString="⼦丑寅卯⾠巳午未申⾣戌亥";var numString="⼀⼆三四五六七⼋九⼗";var monString="正⼆三四五六七⼋九⼗冬腊";var weekString="⽇⼀⼆三四五六" CalendarData = new Array( 0xA4B,0x5164B,0x6A5,0x6D4,0x415B5,0x2B6,0x957,0x2092F,0x497,0x60C96, 0xD4A,0xEA5,0x50DA9,0x5AD,0x2B6,0x3126E, 0x92E,0x7192D,0xC95,0xD4A, 0x61B4A,0xB55,0x56A,0x4155B, 0x25D,0x92D,0x 0x49B,0x41497,0xA4B,0xA164B, 0x6A5,0x6D4,0x615B4,0xAB6,0x957,0x5092F,0x497,0x64B, 0x30D4A,0xEA5,0x80D65,0x5AC,0xAB6,0x5126D,0x92E,0xC96, 0x41A95,0xD4A,0xDA5,0x20B55,0x56A,0x7155B,0x25D,0x92D,0x5192B,0xA95, 0xB4A,0x416AA,0xAD5,0x90AB5,0x4BA,0xA5B, 0x60A57,0x52B,0xA93,0x40E95); madd[0]=0;madd[1]=31;madd[2]=59;madd[3]=90;madd[4]=120;madd[5]=151;madd[6]=181;madd[7]=212;madd[8]=243;madd[9]=273;madd[10]=304;madd[11]=334;function GetBit(m,n) { return (m>>n)&1; }function e2c(){TheDate= (arguments.length!=3) ? new Date() : new Date(arguments[0],arguments[1],arguments[2]);var total,m,n,k;var isEnd=false;var tmp=TheDate.getFullYear();total=(tmp-1921)*365+Math.floor((tmp-1921)/4)+madd[TheDate.getMonth()]+TheDate.getDate()-38; if (TheDate.getYear()%4==0&&TheDate.getMonth()>1) { total++;} for(m=0;;m++) { k=(CalendarData[m]<0xfff)?11:12; for(n=k;n>=0;n--) { if(total<=29+GetBit(C function GetcDateString(){ var tmp=""; tmp+=tgString.charAt((cYear-4)%10);tmp+=dzString.charAt((cYear-4)%12);tmp+="年 ";if(cMonth<1) { tmp+="(闰)"; tmp+=monString.charAt(-cMonth-1); } else {tmp+=monString.charAt(cMonth-1);} tmp+="⽉"; tmp+=(cDay<11)?"初":((cDay<20)?"⼗":((cDay<30)?"廿":"三⼗"));if (cDay%10!=0||cDay==10) { tmp+=numString.charAt((cDay-1)%10); } return tmp;}function GetLunarDay(solarYear,solarMonth,solarDay){if (solarYear<1921 || solarYear>2020) { return "";} else { solarMonth = (parseInt(solarMonth)>0) ? (solarMonth-1) : 11; e2c(solarYear,solarMonth,solarDay); return GetcDateString(); }}var D=new Date();var yy=D.getFullYear();var mm=D.getMonth()+1;var dd=D.getDate();var ww=D.getDay();var ss=parseInt(D.getTime() / 1000);function getFullYear(d){// 修正firefox下year错误yr=d.getYear();if(yr<1000)yr+=1900;return yr;}function showDate() {var sValue = getFullYear(dNow)+"年"+(dNow.getMonth()+1)+"⽉"+dNow.getDate()+"⽇"+" "+sWeek[dNow.getDay()]+" ";sValue+=GetLunarDay(yy,mm,dd);document.getElementById("pDate").innerHTML = sValue;};window.onload=showDate;</script>知道如何获取农历,如何呢获取当前⽇期也很简单。

原生JavaScript实现日历功能代码实例(无引用Jq)

原生JavaScript实现日历功能代码实例(无引用Jq)

原⽣JavaScript实现⽇历功能代码实例(⽆引⽤Jq)这篇⽂章主要介绍了原⽣JavaScript实现⽇历功能代码实例(⽆引⽤Jq),⽂中通过⽰例代码介绍的⾮常详细,对⼤家的学习或者⼯作具有⼀定的参考学习价值,需要的朋友可以参考下成品显⽰,可左右切换⽉份html 代码<!DOCTYPE html><html><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>移动端⽇历</title><link rel="stylesheet" href="./css/calendar.css" rel="external nofollow" ></head><body><div id="calendarElement"><div class="header"><div class="prev"><i class="previ"></i></div><div class="date"></div><div class="next"><i class="nexti"></i></div></div><div class="content"><div class="week"><div>⽇</div><div>⼀</div><div>⼆</div><div>三</div><div>四</div><div>五</div><div>六</div></div><div class="weekMany clearfloat"></div></div></div><script src="./js/calendar.js"></script></body></html>css代码*{margin: 0;padding: 0;}/*清除浮动代码*/.clearfloat:after{display:block;clear:both;content:"";visibility:hidden;height:0}.clearfloat{zoom:1}#calendarElement{margin: 100px auto;width: 80%;box-shadow: 0 0 10px #999999;}#calendarElement>.header{height: 80px;background-color: coral;display: flex;border-bottom: 1px solid #fff;}#calendarElement>.header .prev{width: 20%;position: relative;}height: 20px;display: block;position: absolute;left: 50%;top: 50%;margin-top: -10px;margin-left: -10px;transform: rotate(45deg);border: 2px solid #fff;border-right: none;border-top: none;}#calendarElement>.header .next{position: relative;}#calendarElement>.header .next i{width: 20px;height: 20px;display: block;position: absolute;left: 50%;top: 50%;margin-top: -10px;margin-left: -10px;transform: rotate(45deg);border: 2px solid #fff;border-left: none;border-bottom: none;}#calendarElement>.header .date{width: 60%;font-size: 22px;line-height: 80px;color: #fff;text-align: center;}#calendarElement>.header .next{width: 20%;}#calendarElement>.content >.week{box-sizing: border-box;width: 100%;height: 40px;color: #fff;display: flex;padding: 0 1%;}#calendarElement>.content >.week >div{width: 14%;text-align: center;line-height: 40px;}#calendarElement>.content >.weekMany{padding-top: 5px;padding-bottom: 15px;}#calendarElement>.content >.weekMany>div{float: left;width: 14.28%;height: 40px;text-align: center;line-height: 40px;font-size: 14px;}#calendarElement>.content >.weekMany>.otherMonth{color: #999999}JS代码var currentTime=""; //当前时间年⽉⽇var dom=document.querySelector("#calendarElement"); //承载元素var color="";getCurrentTime();randomColor();function getCurrentTime(){ //获取当前时间var time=new Date();var year=time.getFullYear();var month=time.getMonth()+1;var day=time.getDate();if(month<10){month="0"+month}var data=year+ "-" +month;currentTime=year+ "-" +month+"-"+day;document.querySelector(".date").innerHTML=data;};dom.addEventListener("click",function(e){if(e.target.className=="previ" || e.target.className=="prev"){getMonths("prev")}else if(e.target.className=="nexti" || e.target.className=="next"){getMonths("next")}})function showDay(){var html="";var MonthOne=currentTime;var yearMonth=currentTime.split('-').slice(0,2);yearMonth=yearMonth.join('-');document.querySelector(".date").innerHTML=yearMonth;MonthOne=MonthOne.split('');MonthOne.splice(8,2,"01")MonthOne=MonthOne.join('');var monthLen=getMonthLength(MonthOne); //每⽉有多少天var weekMany=new Date(MonthOne).getDay(); //每⽉⼀号是星期⼏html+=getPrevMonthHtml(weekMany);html+=getNowMonthHtml(monthLen);html+=getNextMonthHtml(weekMany,monthLen);document.querySelector(".weekMany").innerHTML=html;}function getPrevMonthHtml(weekMany){var html="";var lastMonth=currentTime.substring(0, 7); //得出年⽉lastMonth=lastMonth.split('-')if(lastMonth[1]-1==0){lastMonth[1]=12;lastMonth[0]=lastMonth[0]-1;}else if(lastMonth[1]-1<10){lastMonth[1]="0"+(lastMonth[1]-1);}lastMonth=lastMonth.join('-');var monthLen=getMonthLength(lastMonth);var start=monthLen-weekMany;for(var i=start+1;i<=monthLen;i++){html+='<div class="otherMonth day" data-date="'+lastMonth+'-'+i+'">'+i+'</div>';}return html;}function getNowMonthHtml(monthLen){var html="";var MonthOne=currentTime.substring(0, 7); //得出年⽉var today=currentTime.split('-')[2];for(var i=1;i<=monthLen;i++){if(i<10){var q="0"+i;}else{var q=i;}if(i==today){html+='<div class="thisMonth day" style="background-color:'+color+';color:#fff" data-date="'+MonthOne+'-'+q+'">'+i+'</div>'; }else{html+='<div class="thisMonth day" data-date="'+MonthOne+'-'+q+'">'+i+'</div>';}}return html;}function getNextMonthHtml(weekMany,monthLen){var html="";var daynum=weekMany+monthLen;if(daynum%7==0){}else{var num=daynum%7;var lessNum=7-num; //差⼏天var lowerMonth=currentTime.substring(0, 7); //得出年⽉lowerMonth=lowerMonth.split('-')if(lowerMonth[1]+1==13){lowerMonth[1]="0"+1;lowerMonth[0]=+lowerMonth[0]+1;}else{lowerMonth[1]=+lowerMonth[1]+1;if(lowerMonth[1]<10){lowerMonth[1]="0"+lowerMonth[1];}}lowerMonth=lowerMonth.join('-');for(var i=1;i<=lessNum;i++){if(i<10){var q="0"+i}html+='<div class="otherMonth day" data-date="'+lowerMonth+'-'+q+'">'+i+'</div>';}}return html;}function getMonths(around){if(around=="prev"){currentTime=currentTime.split('-');currentTime[1]=currentTime[1]-1;if(currentTime[1]==0){currentTime[1]="12"currentTime[0]=+currentTime[0]-1}if(currentTime[1]<10){currentTime[1]="0"+currentTime[1]}currentTime=currentTime.join('-');showDay();}else if(around=="next"){currentTime=currentTime.split('-');currentTime[1]=+currentTime[1]+1;if(currentTime[1]==13){currentTime[1]="1"currentTime[0]=+currentTime[0]+1}if(currentTime[1]<10){currentTime[1]="0"+currentTime[1]}currentTime=currentTime.join('-');showDay();}}function getMonthLength(date) { // 获取每⽉有多少天let d = new Date(date)// 将⽇期设置为下⽉⼀号d.setMonth(d.getMonth()+1)d.setDate('1')// 获取本⽉最后⼀天d.setDate(d.getDate()-1)return d.getDate()}function randomColor(){ //随机颜⾊color = '#'+Math.floor(Math.random()*16777215).toString(16);if(color.length==6){color+="0"}document.querySelector(".header").style.backgroundColor=color;document.querySelector(".week").style.backgroundColor=color;};以上就是本⽂的全部内容,希望对⼤家的学习有所帮助,也希望⼤家多多⽀持。

显示时间的JavaScript代码

显示时间的JavaScript代码

显示年月日,星期,早晚,时钟<script language="JavaScript"><!--calendar = new Date();day = calendar.getDay();month = calendar.getMonth();date = calendar.getDate();year = calendar.getY ear();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=FFFFFF>"+year +"年");document.write(monthname[month]);document.write(date + "日"+" ");document.write(dayname[day]+" "+"</font>");// January(1月份节日,以下同。

选择时间计算星期几 - 网页特效代码

选择时间计算星期几 - 网页特效代码
}
window.onload=toDate;
</script>
<a href="/">欢迎访问中国建站之家网页特效集</a>�
}
toDay();
}
function toDay(){
vDay=parseInt(document.all.day.options[document.all.day.selectedIndex].value)
document.all("weekday").value="星期"+arr[new Date(vYear,vMonth-1,vDay).getDay()]
脚本说明:
把如下代码加入<body>区域中
<form>
<select id=year onchange=toDate()>
<script>for(i=1970;i<=2010;i++)document.write("<option>"+i+"</option>")</script>
</select>
vMonth=parseInt(month.options[month.selectedIndex].text)
day.length=0;
for(i=0;i<(new Date(vYear,vMonth,0)).getDate();i++){day.options[day.length++].value=day.length;day.options[day.length-1].text=day.length;}

【网页特效】几款还不错的显示日期的代码

【网页特效】几款还不错的显示日期的代码

【网页特效】几款还不错的显示日期的代码第一款:显示效果为“2009年12月31日星期四”<script language="javascript"><!--tmpDate = new Date();date = tmpDate.getDate();month= tmpDate.getMonth() + 1 ;year= tmpDate.getYear();document.write(year);document.write("年");document.write(month);document.write("月");document.write(date);document.write("日 ");myArray=new Array(6);myArray[0]="星期日"myArray[1]="星期一"myArray[2]="星期二"myArray[3]="星期三"myArray[4]="星期四"myArray[5]="星期五"myArray[6]="星期六"weekday=tmpDate.getDay();if (weekday==0 | weekday==6){document.write(myArray[weekday])}else{document.write(myArray[weekday])};// --></script>第二款:带农历的日历——显示效果为“2007年12月14日星期五丙戌年十一月初六”<script language="javascript"><!--var bsYear;var bsDate;var bsWeek;var arrLen=8; //数组长度var sValue=0; //当年的秒数var dayiy=0; //当年第几天var miy=0; //月份的下标var iyear=0; //年份标记var dayim=0; //当月第几天var spd=86400; //每天的秒数var year1999="30;29;29;30;29;29;30;29;30;30;30;29"; //354 var year2000="30;30;29;29;30;29;29;30;29;30;30;29"; //354 var year2001="30;30;29;30;29;30;29;29;30;29;30;29;30"; //384var year2002="30;30;29;30;29;30;29;29;30;29;30;29"; //354 var year2003="30;30;29;30;30;29;30;29;29;30;29;30"; //355 var year2004="29;30;29;30;30;29;30;29;30;29;30;29;30"; //384var year2005="29;30;29;30;29;30;30;29;30;29;30;29"; //354 var year2006="30;29;30;29;30;30;29;29;30;30;29;29;30";var month1999="正月;二月;三月;四月;五月;六月;七月;八月;九月;十月;十一月;十二月"var month2001="正月;二月;三月;四月;闰四月;五月;六月;七月;八月;九月;十月;十一月;十二月"var month2004="正月;二月;闰二月;三月;四月;五月;六月;七月;八月;九月;十月;十一月;十二月"var month2006="正月;二月;三月;四月;五月;六月;七月;闰七月;八月;九月;十月;十一月;十二月"var Dn="初一;初二;初三;初四;初五;初六;初七;初八;初九;初十;十一;十二;十三;十四;十五;十六;十七;十八;十九;二十;廿一;廿二;廿三;廿四;廿五;廿六;廿七;廿八;廿九;三十";var Ys=new Array(arrLen);Ys[0]=919094400;Ys[1]=949680000;Ys[2]=980265600;Ys[3]=1013443200;Ys[4]=1044028800;Ys[5]=1074700800;Ys[6]=1107878400;Ys[7]=1138464000;var Yn=new Array(arrLen); //农历年的名称Yn[0]="己卯年";Yn[1]="庚辰年";Yn[2]="辛巳年";Yn[3]="壬午年";Yn[4]="癸未年";Yn[5]="甲申年";Yn[6]="乙酉年";Yn[7]="丙戌年";var D=new Date();var yy=D.getYear();var mm=D.getMonth()+1;var dd=D.getDate();var ww=D.getDay();if (ww==0) ww="<font color=RED>星期日";if (ww==1) ww="星期一";if (ww==2) ww="星期二";if (ww==3) ww="星期三";if (ww==4) ww="星期四";if (ww==5) ww="星期五";if (ww==6) ww="<font color=RED>星期六";ww=ww;var ss=parseInt(D.getTime() / 1000);if (yy<100) yy="19"+yy;for (i=0;i<arrLen;i++)if (ss>=Ys[i]){iyear=i;sValue=ss-Ys[i]; //当年的秒数}dayiy=parseInt(sValue/spd)+1; //当年的天数var dpm=year1999;if (iyear==1) dpm=year2000;if (iyear==2) dpm=year2001;if (iyear==3) dpm=year2002;if (iyear==4) dpm=year2003;if (iyear==5) dpm=year2004;if (iyear==6) dpm=year2005;if (iyear==7) dpm=year2006;dpm=dpm.split(";");var Mn=month1999;if (iyear==2) Mn=month2001;if (iyear==5) Mn=month2004;if (iyear==7) Mn=month2006;Mn=Mn.split(";");var Dn="初一;初二;初三;初四;初五;初六;初七;初八;初九;初十;十一;十二;十三;十四;十五;十六;十七;十八;十九;二十;廿一;廿二;廿三;廿四;廿五;廿六;廿七;廿八;廿九;三十";Dn=Dn.split(";");dayim=dayiy;var total=new Array(13);total[0]=parseInt(dpm[0]);for (i=1;i<dpm.length-1;i++)total[i]=parseInt(dpm[i])+total[i-1];for (i=dpm.length-1;i>0;i--)if (dayim>total[i-1]){dayim=dayim-total[i-1];miy=i;}bsWeek=ww;bsDate=yy+"年"+mm+"月";bsDate2=dd+"日";bsYear="农历"+Yn[iyear];bsYear2=Mn[miy]+Dn[dayim-1];if (ss>=Ys[7]||ss<Ys[0]) bsYear=Yn[7];function CAL(){document.write(bsDate+bsDate2+" "+bsWeek+" "+bsYear +" "+bsYear2);}//--></script><script language="javascript">CAL();</script>第三款:带秒表的时间——显示效果为“2009年12月31日1:47:24”<div id="timer" style="font:11px tahoma;height:10px;"></div><script>setInterval("timeStr=newDate().toLocaleString();timer.innerText=timeStr;",1000) </script>第四款:带秒表的时间(倒影效果)——显示为“”<div id="timer" style="font:11pxtahoma;height:10px;"></div><div id="timerShadow" style="font:italic 11px tahoma;filter:flipV();height:10px;color:#ccc"></div><script>setInterval("timeStr=newDate().toLocaleString();timer.innerText=timeStr;timerShadow.inn erText=timeStr",1000)</script>。

javascript实现数字时钟特效

javascript实现数字时钟特效

javascript实现数字时钟特效本⽂实例为⼤家分享了javascript实现数字时钟特效的具体代码,供⼤家参考,具体内容如下先看效果,动态数字时钟⽤到了jQuery,但是只是⽤来获取元素,只有⼀点点⾯向对象开发看代码HTML,⾃⼰引⼊jQuery和js,jQuery在前<body><div class="wrapper"><div class="column"><!-- 此div表⽰时的⼗位,只有0,1,2三个 --><div>0</div><div>1</div><div>2</div></div><!-- 以下的内容写到HTML内代码太过冗余,使⽤js写⼊ --><div class="column ten"></div><div class="coln">:</div><div class="column six"></div><div class="column ten"></div><div class="coln">:</div><div class="column six"></div><div class="column ten"></div></div></body>CSS*{margin: 0;padding: 0;}html,body{height: 100%;width: 100%;background-color: #0e141b;overflow: hidden;/* 设置溢出隐藏 */}.wrapper{text-align: center;width: 100%;}.wrapper .column,.wrapper .coln{display: inline-block;vertical-align: top;color: rgba(224,230,235,0.89);font-size: 86px;line-height: 86px;font-weight: 300;}.column{transition: all 300ms ease-in;}.coln{/* 冒号的位置 */transform: translateY(calc(50vh - 83px));}/* 以下都是不同类名对应的透明度 */.visible{opacity: 1;}.close{opacity: 0.25;}.far{opacity: 0.15;}.distance{opacity: 0.05;}JSfunction Index(dom, use) {// 把传进来的DOM元素转数组this.column = Array.from(dom);// 把use转到全局,这个是判断要显⽰的时制是112⼩时还是24⼩时e = use;// 这个数组是后⾯要设置的类名this.classList = ['visible', 'close', 'far', 'distance', 'distance', 'distance', 'distance', 'distance'];this.creatDom();this.start();//开始}// 开始函数Index.prototype.start = function () {var self = this;setInterval(function () {var c = self.getClock();// console.log(c);self.column.forEach(function (ele, index) {var n = + c[index];var offset = n * 86;//移动距离console.log(offset);$(ele).css({'transform': 'translateY(calc(50vh - ' + offset + 'px - 73px))'// 设置移动});Array.from(ele.children).forEach(function (ele2, index2) {var className = self.getClass(n, index2);// 调⽤函数设置类名$(ele2).attr('class', className);})})}, 500);};// 为距离时间不⼀样的元素设置不⼀样的class名Index.prototype.getClass = function (n, i) {var className = this.classList.find(function (ele, index) {return i - index === n || i + index === n;})return className || "";}// 获得时间并且格式化时间,字符串 21:06:09 ==> 210609Index.prototype.getClock = function () {var d = new Date();// 这⾥⾛⼀个三⽬运算符,如果use是真(true)则取值,如果为假则12取余转为12⼩时制return [e ? d.getHours() : d.getHours() % 12 || 12, d.getMinutes(), d.getSeconds()].reduce(function (p, n) { return p + ('0' + n).slice(-2);// 这⾥是吧个位数加0,⽐如1添加⼀个0后得到01,如果是12加0后事012,但是取数值后两位,得到12}, '')};// 由于把HTML元素都写到HTML⽂件⾥,太过冗余,所以使⽤for循环添加进去Index.prototype.creatDom = function () {for (var i = 0; i < 6; i++) {var oDiv = '<div>' + i + '</div>';$(".six").append(oDiv);}for (var i = 0; i < 10; i++) {var iDiv = '<div>' + i + '</div>';$(".ten").append(iDiv);}};// 第⼆个参数,true为24⼩时制,false为12⼩时制new Index($('.column'), true);js的注释我写的⽐较全,应该可以看懂以上就是本⽂的全部内容,希望对⼤家的学习有所帮助,也希望⼤家多多⽀持。

js实现带农历和八字等信息的日历特效_

js实现带农历和八字等信息的日历特效_

js实现带农历和八字等信息的日历特效_ 本文主要介绍了js实现带农历和八字等信息的日历特效,我觉得挺不错的,现在分享给大家,也给大家做个参考自己也尝试着做了一下,收获蛮大,把握了js日历特效的实现原理后,再想增加更多的功能,完全就可以自由发挥了,先在这里分享一下吧,有爱好的可以试试!本文实例为大家分享了js实现带农历等信息的日历特效,代码量很大,供大家参考,具体内容如下效果图:实现代码:代码如下:HTMLHEADTITLE万年历/TITLEMETA content="农历; 阳历; 月历; 节日; 时区; 节气; 八字; 干支; 生肖; gregorian solar; chinese lunar; calendar;" name=keywordsMETA content=All name=robotsMETA content="gregorian solar calendar and chinese lunar calendar" name=descriptionmeta charset="UTF-8"/style type="text/css"body {margin: 0px;padding: 0px;}/style/headbodycenterbrtable cellpadding="0" cellspacing="0" id="1" trtdstyle#cal {width: 434px;border: 1px solid #c3d9ff;font-size: 12px;margin: 8px 0 0 15px;}#cal #top {height: 29px;line-height: 29px; background: #e7eef8; color: #003784;padding-left: 30px; }#cal #top select {font-size: 12px;}#cal #top input {padding: 0;}#cal ul#wk {margin: 0;padding: 0;height: 25px;}#cal ul#wk li {float: left;width: 60px;text-align: center; line-height: 25px; list-style: none;}#cal ul#wk li b {font-weight: normal;color: #c60b02;}#cal #cm {clear: left;border-top: 1px solid #ddd;border-bottom: 1px dotted #ddd; position: relative;}#cal #cm .cell {position: absolute;width: 42px;height: 36px;text-align: center;margin: 0 0 0 9px;}#cal #cm .cell .so {font: bold 16px arial;}#cal #bm {text-align: right;height: 24px;line-height: 24px;padding: 0 13px 0 0;}#cal #bm a {color: 7977ce;}#cal #fd {display: none;position: absolute;border: 1px solid #dddddf; background: #feffcd;padding: 10px;line-height: 21px;width: 150px;}#cal #fd b {font-weight: normal;color: #c60a00;}/style!--[if IE]style#cal #top{padding-top:4px;}#cal #top input{width:65px;}#cal #fd{width:170px;}/style![endif]--div id="cal"div id="top"公元select/select 年select/select月农历span/span年[span/span年]input type="button" value="回到今日" title="点击后跳转回今日" style="padding:0px"/divul id="wk"li一/lili二/lili三/lili四/lili五/lilib六/b/lilib日/b/li/uldiv id="cm"/divdiv id="bm"a target="_blank" onmousedown="returnc({'fm':'alop','title':this.innerHTML,'url':this.href,'p1':al_c(this),'p2':1})"href="javascript:void(0)"历史上的今日/a/div/div/td/tr/table/center/bodyscript language="JavaScript"!--(function() {var S = erAgent.indexOf("MSIE") != -1 !window.opera;function M(C) {return document.getElementById(C)}function R(C) {return document.createElement(C)}var P = [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 K = "甲乙丙丁戊己庚辛壬癸";var J = "子丑寅卯辰巳午未申酉戌亥";var O = "鼠牛虎兔龙蛇马羊猴鸡狗猪";var L = ["小寒", "大寒", "立春", "雨水", "惊蛰", "春分", "清明", "谷雨", "立夏", "小满", "芒种", "夏至", "小暑", "大暑", "立秋", "处暑", "白露", "秋分", "寒露", "霜降", "立冬", "小雪", "大雪", "冬至"];var D = [0, 21208, 43467, 63836, 85337, 107014, 128867, 150921, 173149, 195551, 218072, 240693, 263343, 285989, 308563, 331033, 353350, 375494, 397447, 419210, 440795, 462224, 483532, 504758];var B = "日一二三四五六七八九十";var H = ["正", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "腊"];var E = "初十廿卅";var V = {"0101": "*1元旦节","0214": "情人节","0305": "学雷锋纪念日","0308": "妇女节","0312": "植树节","0315": "消费者权益日","0401": "愚人节","0501": "*1劳动节","0504": "青年节","0601": "国际儿童节","0701": "中国共产党诞辰", "0801": "建军节","0910": "中国老师节","1001": "*3国庆节","1224": "平安夜","1225": "圣诞节"};var T = {"0101": "*2春节","0115": "元宵节","0505": "*1端午节","0815": "*1中秋节","0909": "重阳节","1208": "腊八节","0100": "除夕"};function U(Y) {function c(j, i) {var h = new Date((31556925974.7 * (j - 1900) + D[i] * 60000) + Date.UTC(1900, 0, 6, 2, 5));return (h.getUTCDate())}function d(k) {var h, j = 348;for (h = 32768; h 8; h = 1) {j += (P[k - 1900] h) ? 1 : 0}return (j + b(k))}function a(h) {return (K.charAt(h % 10) + J.charAt(h % 12)) }function b(h) {if (g(h)) {return ((P[h - 1900] 65536) ? 30 : 29)} else {return (0)}}function g(h) {return (P[h - 1900] 15)}function e(i, h) {return ((P[i - 1900] (65536 h)) ? 30 : 29) }function C(m) {var k, j = 0,h = 0;var l = new Date(1900, 0, 31);var n = (m - l) / 86400000;this.dayCyl = n + 40;this.monCyl = 14;for (k = 1900; k 2050 n 0; k++) {h = d(k);n -= h;this.monCyl += 12}if (n 0) {n += h;k--;this.monCyl -= 12}this.year = k;this.yearCyl = k - 1864;j = g(k);this.isLeap = false;for (k = 1; k 13 n 0; k++) {if (j 0 k == (j + 1) this.isLeap == false) { --k;this.isLeap = true;h = b(this.year)} else {h = e(this.year, k)}if (this.isLeap == true k == (j + 1)) {this.isLeap = false}n -= h;if (this.isLeap == false) {this.monCyl++}}if (n == 0 j 0 k == j + 1) {if (this.isLeap) {this.isLeap = false} else {this.isLeap = true;--k;--this.monCyl}}if (n 0) {n += h;--k;--this.monCyl}this.month = k;this.day = n + 1}function G(h) {return h 10 ? "0" + h : h}function f(i, j) {var h = i;return j.replace(/dd?d?d?|MM?M?M?|yy?y?y?/g, function(k) {switch (k) {case "yyyy":var l = "000" + h.getFullYear(); return l.substring(l.length - 4); case "dd":return G(h.getDate());case "d":return h.getDate().toString();case "MM":return G((h.getMonth() + 1));case "M":return h.getMonth() + 1}})}function Z(i, h) {var j;switch (i, h) {case 10:j = "初十";break;case 20:j = "二十";break;case 30:j = "三十";break;default:j = E.charAt(Math.floor(h / 10));j += B.charAt(h % 10)}return (j)}this.date = Y;this.isToday = false;this.isRestDay = false;this.solarYear = f(Y, "yyyy");this.solarMonth = f(Y, "M");this.solarDate = f(Y, "d");this.solarWeekDay = Y.getDay();this.solarWeekDayInChinese = "星期" + B.charAt(this.solarWeekDay);var X = new C(Y);this.lunarYear = X.year;this.shengxiao = O.charAt((this.lunarYear - 4) % 12);this.lunarMonth = X.month;this.lunarIsLeapMonth = X.isLeap;this.lunarMonthInChinese = this.lunarIsLeapMonth ? "闰" + H[X.month - 1] : H[X.month - 1];this.lunarDate = X.day;this.showInLunar = this.lunarDateInChinese = Z(this.lunarMonth, this.lunarDate);if (this.lunarDate == 1) {this.showInLunar = this.lunarMonthInChinese + "月"}this.ganzhiYear = a(X.yearCyl);this.ganzhiMonth = a(X.monCyl);this.ganzhiDate = a(X.dayCyl++);this.jieqi = "";this.restDays = 0;if (c(this.solarYear, (this.solarMonth - 1) * 2) == f(Y, "d")) {this.showInLunar = this.jieqi = L[(this.solarMonth - 1) * 2]}if (c(this.solarYear, (this.solarMonth - 1) * 2 + 1) == f(Y, "d")) {this.showInLunar = this.jieqi = L[(this.solarMonth - 1) * 2 + 1]}if (this.showInLunar == "清明") {this.showInLunar = "清明节";this.restDays = 1}this.solarFestival = V[f(Y, "MM") + f(Y, "dd")]; if (typeof this.solarFestival == "undefined") { this.solarFestival = ""} else {if (/\*(\d)/.test(this.solarFestival)) {this.restDays = parseInt(RegExp.$1);this.solarFestival = this.solarFestival.replace(/\*\d/, "")}}this.showInLunar = (this.solarFestival == "") ? this.showInLunar : this.solarFestival;this.lunarFestival = T[this.lunarIsLeapMonth ? "00" : G(this.lunarMonth) + G(this.lunarDate)];if (typeof this.lunarFestival == "undefined") { this.lunarFestival = ""} else {if (/\*(\d)/.test(this.lunarFestival)) {this.restDays = (this.restDays parseInt(RegExp.$1)) ? this.restDays : parseInt(RegExp.$1);this.lunarFestival = this.lunarFestival.replace(/\*\d/, "")}}if (this.lunarMonth == 12 this.lunarDate == e(this.lunarYear, 12)) {this.lunarFestival = T["0100"];this.restDays = 1}this.showInLunar = (this.lunarFestival == "") ? this.showInLunar : this.lunarFestival;this.showInLunar = (this.showInLunar.length 4) ? this.showInLunar.substr(0, 2) + "..." :this.showInLunar}var Q = (function() {var X = {};X.lines = 0;X.dateArray = new Array(42);function Y(a) {return (((a % 4 === 0) (a % 100 !== 0)) || (a % 400 === 0))}function G(a, b) {return [31, (Y(a) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][b]}function C(a, b) {a.setDate(a.getDate() + b);return a}function Z(a) {var f = 0;var c = new U(new Date(a.solarYear, a.solarMonth - 1, 1));var d = (c.solarWeekDay - 1 == -1) ? 6 : c.solarWeekDay - 1;X.lines = Math.ceil((d + G(a.solarYear, a.solarMonth - 1)) / 7);for (var e = 0; e X.dateArray.length; e++) { if (c.restDays != 0) {f = c.restDays}if (f 0) {c.isRest = true}if (d-- 0 || c.solarMonth != a.solarMonth) { X.dateArray[e] = null;continue}var b = new U(new Date());if (c.solarYear == b.solarYear c.solarMonth ==b.solarMonthc.solarDate == b.solarDate) {c.isToday = true}X.dateArray[e] = c;c = new U(C(c.date, 1));f--}}return {init: function(a) {Z(a)},getJson: function() {return X}}})();var W = (function() {var C = M("top").getElementsByTagName("SELECT")[0];var X = M("top").getElementsByTagName("SELECT")[1];var G = M("top").getElementsByTagName("SPAN")[0]; var c = M("top").getElementsByTagName("SPAN")[1]; var Y = M("top").getElementsByTagName("INPUT")[0]; function a(g) {G.innerHTML = g.ganzhiYear;c.innerHTML = g.shengxiao}function b(g) {C[g.solarYear - 1901].selected = true;X[g.solarMonth - 1].selected = true}function f() {var j = C.value;var g = X.value;var i = new U(new Date(j, g - 1, 1));Q.init(i);N.draw();if (this == C) {i = new U(new Date(j, 3, 1));G.innerHTML = i.ganzhiYear;c.innerHTML = i.shengxiao}var h = new U(new Date());Y.style.visibility = (j == h.solarYear g == h.solarMonth) ? "hidden" : "visible"}function Z() {var g = new U(new Date());a(g);b(g);Q.init(g);N.draw();Y.style.visibility = "hidden"}function d(k, g) {for (var j = 1901; j 2050; j++) { var h = R("OPTION");h.value = j;h.innerHTML = j;if (j == k) {h.selected = "selected"}C.appendChild(h)}for (var j = 1; j 13; j++) {var h = R("OPTION");h.value = j;h.innerHTML = j;if (j == g) {h.selected = "selected"}X.appendChild(h)}C.onchange = f;X.onchange = f}function e(g) {d(g.solarYear, g.solarMonth);G.innerHTML = g.ganzhiYear;c.innerHTML = g.shengxiao;Y.onclick = Z;Y.style.visibility = "hidden" }return {init: function(g) {e(g)},reset: function(g) {b(g)}}})();var N = (function() {function C() {var Z = Q.getJson();var c = Z.dateArray;M("cm").style.height = Z.lines * 38 + 2 + "px"; M("cm").innerHTML = "";for (var a = 0; a c.length; a++) {if (c[a] == null) {continue}var X = R("DIV");if (c[a].isToday) {X.style.border = "1px solid #a5b9da";X.style.background = "#c1d9ff"}X.className = "cell";X.style.left = (a % 7) * 60 + "px";X.style.top = Math.floor(a / 7) * 38 + 2 + "px"; var b = R("DIV");b.className = "so";b.style.color = ((a % 7) 4 || c[a].isRest) ?"#c60b02" : "#313131";b.innerHTML = c[a].solarDate; X.appendChild(b);var Y = R("DIV");Y.style.color = "#666";Y.innerHTML = c[a].showInLunar; X.appendChild(Y);X.onmouseover = (function(d) { return function(f) {F.show({dateIndex: d,cell: this})}})(a);X.onmouseout = function() {F.hide()};M("cm").appendChild(X)}var G = R("DIV");G.id = "fd";M("cm").appendChild(G);F.init(G)}return {draw: function(G) {C(G)}}})();var F = (function() {var C;function Y(e, c) {if (arguments.length 1) {var b = /([.*+?^=!:${}()|[\]\/\\])/g,Z = "{".replace(b, "\\$1"),d = "}".replace(b, "\\$1");var a = new RegExp("#" + Z + "([^" + Z + d + "]+)" + d, "g");if (typeof(c) == "object") {return e.replace(a, function(f, h) {var g = c[h];return typeof(g) == "undefined" ? "" : g})}}return e}function G(b) {var a = Q.getJson().dateArray[b.dateIndex];var Z = b.cell;var c = "#{solarYear} 年#{solarMonth} 月#{solarDate} 日 #{solarWeekDayInChinese}";c += "brb农历#{lunarMonthInChinese}月#{lunarDateInChinese}/b";c += "br#{ganzhiYear}年#{ganzhiMonth}月#{ganzhiDate}日";if (a.solarFestival != "" || a.lunarFestival != "" || a.jieqi != "") {c += "brb#{lunarFestival} #{solarFestival} #{jieqi}/b"}C.innerHTML = Y(c, a);C.style.top = Z.offsetTop + Z.offsetHeight - 5 + "px";C.style.left = Z.offsetLeft + Z.offsetWidth - 5 + "px";C.style.display = "block"}function X() {C.style.display = "none"}return {show: function(Z) {G(Z)},hide: function() {X()},init: function(Z) {C = Z}}})();var I = (function() {var G = M("bm").getElementsByTagName("A")[0]; function C(X) {G.href = "l以上就是本文的全部内容,盼望对大家学习javascript 程序设计有所关心。

公历和农历转换的JS代码

公历和农历转换的JS代码

公历和农历转换的JS代码<!--function CalConv(M){FIRSTYEAR = 1936;LASTYEAR = 2031;LunarCal = [new tagLunarCal(23, 3, 2, 17, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0 ), /* 1936 */new tagLunarCal( 41, 0, 4, 23, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1 ),new tagLunarCal( 30, 7, 5, 28, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1 ),new tagLunarCal( 49, 0, 6, 33, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1 ),new tagLunarCal( 38, 0, 0, 38, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ), /* 1940 */new tagLunarCal( 26, 6, 2, 44, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0 ),new tagLunarCal( 45, 0, 3, 49, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ),new tagLunarCal( 35, 0, 4, 54, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1 ),new tagLunarCal( 24, 4, 5, 59, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1 ), /* 1944 */new tagLunarCal( 43, 0, 0, 5, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1 ),new tagLunarCal( 32, 0, 1, 10, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1 ),new tagLunarCal( 21, 2, 2, 15, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1 ),new tagLunarCal( 40, 0, 3, 20, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1 ), /* 1948 */new tagLunarCal( 28, 7, 5, 26, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ),new tagLunarCal( 47, 0, 6, 31, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1 ),new tagLunarCal( 36, 0, 0, 36, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ),new tagLunarCal( 26, 5, 1, 41, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1 ), /* 1952 */new tagLunarCal( 44, 0, 3, 47, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1 ),new tagLunarCal( 33, 0, 4, 52, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0 ),new tagLunarCal( 23, 3, 5, 57, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1 ),new tagLunarCal( 42, 0, 6, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1 ), /* 1956 */new tagLunarCal( 30, 8, 1, 8, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0 ),new tagLunarCal( 48, 0, 2, 13, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0 ),new tagLunarCal( 38, 0, 3, 18, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 ),new tagLunarCal( 27, 6, 4, 23, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0 ), /* 1960 */new tagLunarCal( 45, 0, 6, 29, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0 ),new tagLunarCal( 35, 0, 0, 34, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1 ),new tagLunarCal( 24, 4, 1, 39, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0 ),new tagLunarCal( 43, 0, 2, 44, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0 ), /* 1964 */new tagLunarCal( 32, 0, 4, 50, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1 ),new tagLunarCal( 20, 3, 5, 55, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0 ),new tagLunarCal( 39, 0, 6, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0 ),new tagLunarCal( 29, 7, 0, 5, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1 ), /* 1968 */new tagLunarCal( 47, 0, 2, 11, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1 ),new tagLunarCal( 36, 0, 3, 16, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0 ),new tagLunarCal( 26, 5, 4, 21, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0, 1 ),new tagLunarCal( 45, 0, 5, 26, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1 ), /* 1972 */new tagLunarCal( 33, 0, 0, 32, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1 ),new tagLunarCal( 22, 4, 1, 37, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1 ),new tagLunarCal( 41, 0, 2, 42, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1 ),new tagLunarCal( 30, 8, 3, 47, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1 ), /* 1976 */new tagLunarCal( 48, 0, 5, 53, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1 ),new tagLunarCal( 37, 0, 6, 58, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1 ),new tagLunarCal( 27, 6, 0, 3, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0 ),new tagLunarCal( 46, 0, 1, 8, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0 ), /* 1980 */new tagLunarCal( 35, 0, 3, 14, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1 ),new tagLunarCal( 24, 4, 4, 19, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1 ),new tagLunarCal( 43, 0, 5, 24, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1 ),new tagLunarCal( 32, 10, 6, 29, 1, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1 ), /* 1984 */new tagLunarCal( 50, 0, 1, 35, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0 ),new tagLunarCal( 39, 0, 2, 40, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1 ),new tagLunarCal( 28, 6, 3, 45, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0 ),new tagLunarCal( 47, 0, 4, 50, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1 ), /* 1988 */new tagLunarCal( 36, 0, 6, 56, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 0 ),new tagLunarCal( 26, 5, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1 ),new tagLunarCal( 45, 0, 1, 6, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0 ),new tagLunarCal( 34, 0, 2, 11, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0 ), /* 1992 */new tagLunarCal( 22, 3, 4, 17, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0 ),new tagLunarCal( 40, 0, 5, 22, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0 ),new tagLunarCal( 30, 8, 6, 27, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1 ),new tagLunarCal( 49, 0, 0, 32, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1 ), /* 1996 */new tagLunarCal( 37, 0, 2, 38, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1 ),new tagLunarCal( 27, 5, 3, 43, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1 ),new tagLunarCal( 46, 0, 4, 48, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1 ), /* 1999 */new tagLunarCal( 35, 0, 5, 53, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1 ), /* 2000 */new tagLunarCal( 23, 4, 0, 59, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ),new tagLunarCal( 42, 0, 1, 4, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ),new tagLunarCal( 31, 0, 2, 9, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0 ),new tagLunarCal( 21, 2, 3, 14, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1 ), /* 2004 */new tagLunarCal( 39, 0, 5, 20, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1 ),new tagLunarCal( 28, 7, 6, 25, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1 ),new tagLunarCal( 48, 0, 0, 30, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1 ),new tagLunarCal( 37, 0, 1, 35, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1 ), /* 2008 */new tagLunarCal( 25, 5, 3, 41, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1 ),new tagLunarCal( 44, 0, 4, 46, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1 ),new tagLunarCal( 33, 0, 5, 51, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ),new tagLunarCal( 22, 4, 6, 56, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ), /* 2012 */new tagLunarCal( 40, 0, 1, 2, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0 ),new tagLunarCal( 30, 9, 2, 7, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1 ),new tagLunarCal( 49, 0, 3, 12, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1 ),new tagLunarCal( 38, 0, 4, 17, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0 ), /* 2016 */new tagLunarCal( 27, 6, 6, 23, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1 ),new tagLunarCal( 46, 0, 0, 28, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0 ),new tagLunarCal( 35, 0, 1, 33, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0 ),new tagLunarCal( 24, 4, 2, 38, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1 ), /* 2020 */new tagLunarCal( 42, 0, 4, 44, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1 ),new tagLunarCal( 31, 0, 5, 49, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0 ),new tagLunarCal( 21, 2, 6, 54, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1 ),new tagLunarCal( 40, 0, 0, 59, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1 ), /* 2024 */new tagLunarCal( 28, 6, 2, 5, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 0 ),new tagLunarCal( 47, 0, 3, 10, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1 ),new tagLunarCal( 36, 0, 4, 15, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1 ),new tagLunarCal( 25, 5, 5, 20, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0 ), /* 2028 */new tagLunarCal( 43, 0, 0, 26, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1 ),new tagLunarCal( 32, 0, 1, 31, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 0 ),new tagLunarCal( 22, 3, 2, 36, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 0 ) ];/* 西曆年每⽉之⽇數 */SolarCal = [ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ];/* 西曆年每⽉之累積⽇數, 平年與閏年 */SolarDays = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365, 396,0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366, 397 ];AnimalIdx = ["⾺ ", "⽺ ", "猴 ", "雞 ", "狗 ", "豬 ", "⿏ ", "⽜ ", "虎 ", "兔 ", "⿓ ", "蛇 " ];LocationIdx = [ "南", "東", "北", "西" ];if (M==0) { //阳历到阴历if (!IsInteger(form_jisuan.yyear.value) || !IsInteger(form_jisuan.ymonth.value) || !IsInteger(form_jisuan.yday.value)) return alert("请输⼊合法阳历年⽉⽇数值"); SolarYear = parseInt(form_jisuan.yyear.value);SolarMonth = parseInt(form_jisuan.ymonth.value);SolarDate = parseInt(form_jisuan.yday.value);if ( SolarYear <= FIRSTYEAR || SolarYear > LASTYEAR ) return alert("请输⼊1936-2031有效年份");sm = SolarMonth - 1;if ( sm < 0 || sm > 11 ) return alert("请输⼊有效⽉份");leap = GetLeap( SolarYear );if ( sm == 1 )d = leap + 28;elsed = SolarCal[sm];if ( SolarDate < 1 || SolarDate > d ) return 3;y = SolarYear - FIRSTYEAR;acc = SolarDays[ leap*14 + sm ] + SolarDate;kc = acc + LunarCal[y].BaseKanChih;Kan = kc % 10;Chih = kc % 12;Location = LocationIdx[kc % 4];Age = kc % 60;if ( Age < 22 )Age = 22 - Age;elseAge = 82 - Age;Age =Age + 3;if (Age < 10)Age=Age+60;Animal = AnimalIdx[ Chih ];if ( acc <= LunarCal[y].BaseDays ) {y--;LunarYear = SolarYear - 1;leap = GetLeap( LunarYear );sm += 12;acc = SolarDays[leap*14 + sm] + SolarDate;}elseLunarYear = SolarYear;l1 = LunarCal[y].BaseDays;for ( i=0; i<13; i++ ) {l2 = l1 + LunarCal[y].MonthDays[i] + 29;if ( acc <= l2 ) break;l1 = l2;}LunarMonth = i + 1;LunarDate = acc - l1;im = LunarCal[y].Intercalation;if ( im != 0 && LunarMonth > im ) {LunarMonth--;if ( LunarMonth == im ) LunarMonth = -im;}if ( LunarMonth > 12 ) LunarMonth -= 12;//alert("农历/阴历⽇期为:"+ LunarYear + "年" + LunarMonth + "⽉" + LunarDate + "⽇" );var showgn = 0;showgn = "农历(阴历)⽇期为:"+ LunarYear + "年" + LunarMonth + "⽉" + LunarDate + "⽇";document.form_jisuan.g2n.value=showgn;//form_jisuan.yyear.value = "";//form_jisuan.ymonth.value = "";//form_jisuan.yday.value = "";return 0;}else/* 阴历转阳历 */{if (!IsInteger(form_jisuan.nyear.value) || !IsInteger(form_jisuan.nmonth.value) || !IsInteger(form_jisuan.nday.value)) return alert("请输⼊合法农历年⽉⽇数值"); LunarYear = parseInt(form_jisuan.nyear.value);LunarMonth = parseInt(form_jisuan.nmonth.value);LunarDate = parseInt(form_jisuan.nday.value);if ( LunarYear < FIRSTYEAR || LunarYear >= LASTYEAR ) return alert("请输⼊1936-2031有效年份");y = LunarYear - FIRSTYEAR ;im = LunarCal[y].Intercalation;lm = LunarMonth;if ( lm < 0 ){if ( lm != -im )return alert("请输⼊有效⽉份");}else if ( lm < 1 || lm > 12 ) return alert("请输⼊有效⽉份");if ( im != 0 ){if ( lm > im )lm++;else if ( lm == -im )lm = im + 1;}lm--;if ( LunarDate > LunarCal[y].MonthDays[lm] + 29 )return alert("农历⽇期不正确");acc = 0;for ( i=0; i < lm;i++) {acc+= LunarCal[y].MonthDays[i] + 29;}acc +=LunarCal[y].BaseDays + LunarDate;leap = GetLeap( LunarYear );for ( i=13; i>=0; i-- ) {if ( acc > SolarDays[leap*14+i] )break;}SolarDate = acc - SolarDays[leap*14 + i] ;if ( i <= 11 ){SolarYear = LunarYear;SolarMonth = i + 1;}else{SolarYear = LunarYear + 1;SolarMonth = i - 11;}leap = GetLeap( SolarYear );y = SolarYear - FIRSTYEAR;//acc = SolarDays[leap][SolarMonth-1] + SolarDate;acc = SolarDays[leap*14 + SolarMonth-1] + SolarDate;weekday = ( acc + LunarCal[y].BaseWeekday ) % 7;kc = acc + LunarCal[y].BaseKanChih;kan = kc % 10;chih = kc % 12;//alert("公历/阳历⽇期为:"+ SolarYear + "年" + SolarMonth + "⽉" + SolarDate + "⽇" );var showng = 0;showng = "公历(阳历)⽇期为:"+ SolarYear + "年" + SolarMonth + "⽉" + SolarDate + "⽇";document.form_jisuan.n2g.value=showng;//form_jisuan.nyear.value = "";//form_jisuan.nmonth.value = "";//form_jisuan.nday.value = "";return 0;}//else结束}/* 闰年, 返回 0 平年, 1 闰年 */function GetLeap( year ){if ( year % 400 == 0 )return 1;else if ( year % 100 == 0 )return 0;else if ( year % 4 == 0 )return 1;elsereturn 0;}function tagLunarCal( d, i, w, k, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13) {this.BaseDays = d; /* 1 ⽉ 1 ⽇到正⽉初⼀的累计⽇ */this.Intercalation = i; /* 闰⽉⽉份. 0==此年沒有闰⽉ */this.BaseWeekday = w; /* 此年 1 ⽉ 1 ⽇为星期减 1 */this.BaseKanChih = k; /* 此年 1 ⽉ 1 ⽇之⼲⽀序号减 1 */this.MonthDays = [ m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13 ]; /* 此农历年每⽉之⼤⼩, 0==⼩⽉(29⽇), 1==⼤⽉(30⽇) */}//--><!--function OpenWin( url ) {return window.open( url, 'coop', 'width=320,height=350,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=0,resizable=1' );}function IsInteger(string ,sign){var integer;if ((sign!=null) && (sign!='-') && (sign!='+')){alert('IsInter(string,sign)的参数出错:nsign为null或"-"或"+"');return false;}integer = parseInt(string);if (isNaN(integer)){return false;}else if (integer.toString().length==string.length){if ((sign==null) || (sign=='-' && integer<0) || (sign=='+' && integer>0)){return true;}elsereturn false;}elsereturn false;}//-->调⽤⽅式:<label>请选择阳历⽇期</label><select size="1" name="yyear" class="select"><option value="1937">1937</option><option value="1938">1938</option><option value="1939">1939</option><option value="1940">1940</option><option value="1941">1941</option><option value="1942">1942</option><option <select size="1" name="ymonth" class="select"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</ <select size="1" name="yday" class="select"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</<input onclick="CalConv(0)" class="button" type="button" value="阳历转阴历">。

调用时间日期JS代码

调用时间日期JS代码

关于调用日期-年月日的JS代码格式显示为:5月13日18:20 星期日鼠标经过还会显示农历的日期。

第一步:将下列代码放在要显示时间日期的地方<div id="riqi" style=" margin-left:6px; width:201px; float:left; margin-top:6px; height: 16px;"><span id="clock" onmouseover="document.all.lunar.style.display='block';this.style.display='none'"><fontcolor="#000000"><span id="clockspan">日期</span></font></span><span id="lunar" onmouseout="this.style.display='none';document.all.clock.style.display='block'"style="display:none;"><font color="#000000" bgcolor="#ffffe6"><span id="lunarspan">农历</span></font></span><script language="javascript" type="text/javascript" src="time.js"></script></div>第二步:用记事本输入以下代码(JS文件),并以js后缀保存,这里本人把阿它命名为time.js,名字可以随你自己取。

纯js时钟特效详细代码分析实例教程

纯js时钟特效详细代码分析实例教程

纯js时钟特效详细代码分析实例教程电⼦时钟是⽹上常见的功能,在学习date对象和定时器功能时,来完成⼀个电⼦时钟的制作是不错的选择。

学习本教程之前,读者需要具备html和css技能,同时需要有简单的javascript基础。

先准备⼀个html元素,⽤来放置时钟。

新建⼀个div元素,它的id命名为clock,如下所⽰:<div id="clock" class="clock_con"></div><!--基础时钟元素-->本实例电⼦时钟的格式设定为 (yyyy-MM-dd hh:mm:ss) ,⽤js来组合⼀个简单的时钟字符串放到clock元素中。

本实例把时钟功能封装到函数中,所以先创建⼀个creatClock函数,在creatClock中再来编写具体代码。

建议在完成某⼀个前端功能时,应先分析功能的具体操作。

再根据具体操作把实现功能的⽅法分成多个步骤,接下来⼀个步骤⼀个步骤去完成它。

来看⼀下⽤js组合这样⼀串字符,需要哪些步骤:1 调⽤date对象,获取计算机的本地时间 1.1 调⽤date对象 1.2 获取当前年份 1.3 获取当前⽉份,⽉份是从0开始计数,所以需要加1才是正确的⽉份 1.4 获取当前⽇期 1.5 获取当前⼩时 1.6 获取分钟 1.7 获取秒数2. 格式化获取到的时间数据 2.1 单数字前添加字符串0,⽤以符合时钟格式 2.2 组合时间数据为字符串3. 在clock元素中实时显⽰时间 3.1 获取clock元素 3.2 修改clock元素中的时间 3.3 使⽤定时器实时更新时间具体代码如下:function fnCreatClock(){//声明时间相关变量var dLocal,nYear,nMonth,nDate,nHours,nMinutes,nSeconds;//1 获取计算机本地时间function fnGetDate(){//1.1 调⽤date对象dLocal = new Date();//1.2 获取当前年份nYear = dLocal.getFullYear();//1.3 获取当前⽉份,⽉份是从0开始计数,所以需要加1才是正确的⽉份nMonth = dLocal.getMonth() + 1;//1.4 获取当前⽇期nDate = dLocal.getDate();//1.5 获取当前⼩时nHours = dLocal.getHours();//1.6 获取分钟nMinutes = dLocal.getMinutes();//1.7 获取秒数nSeconds = dLocal.getSeconds();}//2.1 封装⼀个函数,⽤于把单数字前添加字符串0,例如1改为01function fnToDouble(num){//声明⼀个返回结果var sResult = '';if(num<10){//判断数字⼩于10则是单数字,需要在前⾯添加字符串0sResult = '0' + num;}else{//数字为10以上转换为字符串sResult = '' + num;}//返回格式化后的字符串return sResult;}function fnFormatDate(){//2.2 组合时间数据为字符串。

JS实现处理时间,年月日,星期的公共方法示例

JS实现处理时间,年月日,星期的公共方法示例

JS实现处理时间,年⽉⽇,星期的公共⽅法⽰例本⽂实例讲述了JS实现处理时间,年⽉⽇,星期的公共⽅法。

分享给⼤家供⼤家参考,具体如下:在项⽬中⽤到的,⽤js 来得到年⽉⽇,星期,当前多少个周的函数,备忘在这⾥,以后参考。

Date.prototype.getWeek = function(){var firstDayOfYear = new Date(this.getFullYear(),0,1);var millOfDay = 24*60*60*1000;return Math.ceil((((this - firstDayOfYear) / millOfDay) + firstDayOfYear.getDay()+1)/7);};/*01 October 2013-10:20:2001 November 2013-10:20:2001 December 2013-10:20:2008 October 2013-01:55 pm*/var monthMapping = {"January" : "01","February" : "02","March" : "03","April" : "04","May" : "05","June" : "06","July" : "07","August" : "08","September" : "09","October" : "10","November" : "11","December" : "12"};function formatAmPm() {var dateTimeStr = arguments[0] ;var dateStr = dateTimeStr.split("-");if (lang.currentLang == "zh_CN" || lang.currentLang == "zh_TW"){var s_year = lang.getMessage('yearCn') ;var s_month = lang.getMessage('monthCn') ;var s_day = lang.getMessage('dayCn') ;var dateArray = dateStr[0].split(" ") ;var s_time = dateStr[1].split(" ")[1] == "am" ? lang.getMessage('amCn') :lang.getMessage('pmCn') ;var ret = dateArray[2] + s_year + monthMapping[dateArray[1]] + s_month + dateArray[0] + s_day + " " + s_time + dateStr[1].split(" ")[0] ; if ( arguments.length > 1 ){/*admin feature ,so using en date*/ret = arguments[1] ? dateStr[0] : dateStr[1] ;}return ret ;}else{if ( arguments.length > 1 ){return arguments[1] ? dateStr[0] : dateStr[1] ;}else{return dateStr[0] + " " + dateStr[1] ;}}}function formatDate(dateTime, pattern) {if(pattern == "" || pattern == null) {pattern = "/";}var date = new Date(dateTime);var year = date.getFullYear();var month = date.getMonth()+1;month = month <10 ? '0'+month : month;var day = date.getDate();day = day <10 ? '0'+day : day;return month + pattern + day + pattern + year;}function formatDateDDMMYYYY(dateTime) {var ymd = dateTime.split(" ")[0];var dateArray = ymd.split("-");return dateArray[2]+"."+dateArray[1]+"."+dateArray[0];}/**** @param dateTime YYYY-MM-DD hh:mm:ss*/function formatDateDDMMYY(dateTime){var ymd = dateTime.split(" ")[0];var dateArray = ymd.split("-");return dateArray[2]+"."+dateArray[1]+"."+dateArray[0].substring(2);}/**********************calculate date*****************************/var MONTH = [{key:"Jan.",value:1},{key:"Feb.",value:2},{key:"Mar.",value:3},{key:"Apr.",value:4},{key:"May.",value:5},{key:"Jun.",value:6},{key:"Jul.",value:7},{key:"Aug.",value:8},{key:"Sept.",value:9},{key:"Oct.",value:10},{key:"Nov.",value:11},{key:"Dec.",value:12}];var DAYS = [31,28,31,30,31,30,31,31,30,31,30,31];function getYears(){var years = [];var date = new Date();var year = date.getFullYear();var minYear = year - 10;for(var currentYear=minYear;currentYear <= year;currentYear++){years.push(currentYear);}return years;};function fillinMonthOptions(id,currentMonth){$("#" + id).get(0).options.length = 0;for(var i= 0;i<MONTH.length; i++){if (MONTH[i].value == currentMonth){$("#" + id).append("<option value="+MONTH[i].value+" selected=\"selected\">"+MONTH[i].key+"</option>"); }else{$("#" + id).append("<option value="+MONTH[i].value+">"+MONTH[i].key+"</option>");}}};function fillinAllMonthOptions(monthIds,currentMonth){//var monthIds = ["loginMonth_1","loginMonth_2","auditMonth_1","auditMonth_2"];for (var i=0;i<monthIds.length;i++){fillinMonthOptions(monthIds[i],currentMonth);};};function fillinYearOptions(id,years,currentYear){$("#" + id).get(0).options.length = 0;for(var i= 0;i<years.length; i++){if (years[i] == currentYear){$("#" + id).append("<option value="+years[i]+" selected=\"selected\">"+years[i]+"</option>");}else{$("#" + id).append("<option value="+years[i]+">"+years[i]+"</option>");}}};function fillinAllYearOptions(yearIds,currentYear){//var yearIds = ["loginYear","auditYear"];years = getYears();for(var i= 0;i<yearIds.length; i++){fillinYearOptions(yearIds[i],years,currentYear);}};function isLeapYear(year){return (year % 4 === 0) && (year % 100 !==0) || (year % 400 === 0);}/*get days of a month*/function getMonthDays(year,month){var monthDays = DAYS[month-1];if (isLeapYear(year) && month == 2){monthDays = 29;}return monthDays;}function fillinDay(id,monthDays){$("#" + id).get(0).options.length = 0;for(var i=1;i<=monthDays;i++){$("#" + id).append("<option value="+i+">"+i+"</option>");}}function fiilinDays(year,month,dayIds){var monthDays = getMonthDays(year,month);for(var i=0;i<dayIds.length;i++){fillinDay(dayIds[i],monthDays);}}function getWeeksOfYear(year){var firstDayOfYear = new Date(year,0,1);var days = firstDayOfYear.getDay() + (isLeapYear(year) ? 366 : 365);return Math.ceil(days/7);}function getCurrentWeekNo(){var currentDate = new Date();var firstDay = new Date(currentDate.getFullYear(),0,1);var dayms = 24 * 60 * 60 * 1000;var numday = ((currentDate - firstDay) / dayms );var weeks = Math.ceil((numday + firstDay.getDay() + 1) / 7);return weeks;}function getWeekRangeOfWeek(year,weekNo){var tmpDate = new Date("1/20/" + year);var numOfDaysPastSinceLastMonday = tmpDate.getDay()-1;tmpDate.setDate(tmpDate.getDate() - numOfDaysPastSinceLastMonday);var weekNoToday = tmpDate.getWeek();var weeksInFuture = weekNo - weekNoToday;tmpDate.setDate(tmpDate.getDate() + (7 * weeksInFuture) );var rangeFrom = tmpDate.getDate() + "/" + MONTH[tmpDate.getMonth()].key;tmpDate.setDate(tmpDate.getDate() + 6);var rangeTo = tmpDate.getDate() + "/" + MONTH[tmpDate.getMonth()].key ;return weekNo + "_#_" + rangeFrom + "_#_" + rangeTo ;}function fillinWeek(weekId,year){$("#" + weekId).get(0).options.length = 0;var weeksOfYear = getWeeksOfYear(year);var weeks = [];for(var i=0;i<weeksOfYear;i++){weeks.push(getWeekRangeOfWeek(year,i+1));}for(var j=0;j<weeks.length;j++){var week = weeks[j].split("_#_");$("#" + weekId).append("<option value="+week[0]+">"+week[0] + "(" + week[1]+"-"+week[2]+")</option>"); }}function fillinWeeks(year,weekIds){for (var i=0;i<weekIds.length;i++){fillinWeek(weekIds[i],year);}}PS:这⾥再为⼤家推荐⼏款⽐较实⽤的天数计算在线⼯具供⼤家使⽤:更多关于JavaScript相关内容感兴趣的读者可查看本站专题:《》、《》、《》、《》及《》希望本⽂所述对⼤家JavaScript程序设计有所帮助。

js编写当天简单日历效果(实现代码)

js编写当天简单日历效果(实现代码)

下面小编就为大家带来一篇js编写当天简单日历效果【实现代码】。

小编觉得挺不错的,现在分享给大家,也给大家做个参考之前一直很想用javascript写一个日历,但是因为完全没有好的思路,所以迟迟没有尝试。

最近在网上刚好看到用javascript编写的简单日历的例子,代码量虽然不大,但是我觉得很好地阐述了js日历的实现原理。

自己也尝试着做了一下,收获蛮大,掌握了基本的实现原理后,再想增加更多的功能,完全就可以自由发挥了,先在这里分享一下吧,有兴趣的可以试试!一.表格行数问题既然要显示日期表格的话,首先得知道这个表格有多少行多少列,列数是已经确定的,从星期天(日历上第1列是星期天)到星期六一共7列。

要解决行数问题之前,还得先知道这个月的第1天是星期几,因为每个月的1号并不都是从日历上的星期天开始排的,可能1号是星期五,星期六也说不定,所以1号的左边部分,就得用空表格代替了。

那么用多少个空表格代替呢,这里就得用到getDay()方法了,该方法返回数组[0-6]中的一个数字,0代表星期天,1代表星期一,2代表星期二,以此类推。

所以如果一个月的1号是星期五的话,那么刚好左边需要5个空表格代替。

然后,假如一个月有31天,最后求出的表格行数就是:var tr_nums = Math.ceil((5 + 31)/7);&nbsp;当然,并不是每个月都是31天,所以我们得创建一个包含12个月份的数组,每个元素代表每个月份所包含的天数。

但是2月份比较特殊,闰年的2月份有29天,平年的2月份只有28天。

所以,在创建数组之前,得自己创建一个判断闰年的函数://如果当前年份能被4整除但是不能被100整除或者能被400整除,即可确定为闰年,返回1,否则返回0function isLeap(year) {&nbsp;return year % 4 == 0 ? (year % 100 != 0 ? 1 : (year % 400 == 0 ? 1 : 0)) : 0;}然后我们创建一个月份数组:var days_per_month = new Array(31, 28 + isLeap(year), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);&nbsp;这样就能保证无论是平年还是闰年都会取出正确的天数,下面的代码用于获取今天的相关信息:var today = new Date(), &nbsp; &nbsp; &nbsp; //获取当前日期&nbsp; y = today.getFullYear(), &nbsp; &nbsp; //获取日期中的年份&nbsp; m = today.getMonth(), &nbsp; &nbsp; &nbsp;//获取日期中的月份(需要注意的是:月份是从0开始计算,获取的值比正常月份的值少1)&nbsp; d = today.getDate(), &nbsp; &nbsp; &nbsp; //获取日期中的日(方便在建立日期表格时高亮显示当天)&nbsp; firstday = new Date(y, m, 1), &nbsp;//获取当月的第一天&nbsp; dayOfWeek = firstday.getDay(), &nbsp;//判断第一天是星期几(返回[0-6]中的一个,0代表星期天,1代表星期一,以此类推)&nbsp; days_per_month = new Array(31, 28 + isLeap(y), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31), //创建月份数组所以最后就可以获取当月所需表格的行数:var str_nums = Math.ceil((dayOfWeek + days_per_month[m]) / 7); //确定日期表格所需的行数二.打印日历表格&nbsp; &nbsp;表格本身是一个二维数组,所以让for大师出来跑两个循环就搞定啦,代码如下:for (i = 0; i &lt; str_nums; i += 1) { &nbsp; //第一层for循环创建tr标签&nbsp; document.write('&lt;tr&gt;');&nbsp; for (k = 0; k &lt; 7; k++) { &nbsp; &nbsp; &nbsp;//第二层for循环创建td标签&nbsp; &nbsp;var idx = 7 * i + k; &nbsp; &nbsp; &nbsp; &nbsp;//为每个表格创建索引,从0开始&nbsp; &nbsp;var date = idx - dayOfWeek + 1; &nbsp;//将当月的1号与星期进行匹配&nbsp; &nbsp;//do something else&nbsp; }&nbsp; document.write('&lt;/tr&gt;');&nbsp; }三.附上完整的js日历代码&lt;script&gt;&nbsp; //判断当前年份是否是闰年(闰年2月份有29天,平年2月份只有28天)&nbsp; function isLeap(year) {&nbsp; return year % 4 == 0 ? (year % 100 != 0 ? 1 : (year % 400 == 0 ? 1 : 0)) : 0;&nbsp; }&nbsp; var i, k,&nbsp; today = new Date(), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //获取当前日期&nbsp; y = today.getFullYear(), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//获取日期中的年份&nbsp; m = today.getMonth(), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//获取日期中的月份(需要注意的是:月份是从0开始计算,获取的值比正常月份的值少1)&nbsp; d = today.getDate(), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//获取日期中的日(方便在建立日期表格时高亮显示当天)&nbsp; firstday = new Date(y, m, 1), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//获取当月的第一天&nbsp; dayOfWeek = firstday.getDay(), &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //判断第一天是星期几(返回[0-6]中的一个,0代表星期天,1代表星期一,以此类推) &nbsp; days_per_month = new Array(31, 28 + isLeap(y), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31), &nbsp; &nbsp; &nbsp; &nbsp; //创建月份数组&nbsp; str_nums = Math.ceil((dayOfWeek + days_per_month[m]) / 7); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//确定日期表格所需的行数&nbsp; document.write("&lt;table cellspacing='0'&gt;&lt;tr&gt;&lt;th&gt;日&lt;/th&gt;&lt;th&gt;一&lt;/th&gt;&lt;th&gt;二&lt;/th&gt;&lt;th&gt;三&lt;/th&gt;&lt;th&gt;四&lt;/th&gt;&lt;th&gt;五&lt;/th&gt;&lt;th&gt;六&lt;/th&gt;&lt;/tr&gt;"); //打印表格第一行(显示星期)&nbsp; for (i = 0; i &lt; str_nums; i += 1) { &nbsp; &nbsp; &nbsp; &nbsp; //二维数组创建日期表格&nbsp; document.write('&lt;tr&gt;');&nbsp; for (k = 0; k &lt; 7; k++) {&nbsp; &nbsp;var idx = 7 * i + k; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//为每个表格创建索引,从0开始&nbsp; &nbsp;var date = idx - dayOfWeek + 1; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//将当月的1号与星期进行匹配&nbsp; &nbsp;(date &lt;= 0 || date &gt; days_per_month[m]) ? date = ' ': date = idx - dayOfWeek + 1; &nbsp;//索引小于等于0或者大于月份最大值就用空表格代替&nbsp; &nbsp;date == d ? document.write('&lt;td class="today"&gt;' + date + '&lt;/td&gt;') : document.write('&lt;td&gt;' + date + '&lt;/td&gt;'); &nbsp;//高亮显示当天&nbsp; }&nbsp; document.write('&lt;/tr&gt;');&nbsp; }&nbsp; document.write('&lt;/table&gt;');&nbsp;&lt;/script&gt;css部分大家就自由发挥吧,当前时间是2016年5月2号,效果图如下:以上这篇js编写当天简单日历效果【实现代码】就是小编分享给大家的全部内容了,希望能给大家一个参考。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
CalendarData[7]=0x92D;
CalendarData[8]=0x5192B;
CalendarData[9]=0xA95;
CalendarData[10]=0xB4A;
CalendarData[11]=0x416AA;
</script>
<!--下面只是说明与程序代码无关-->
<div style="width:95%; height:auto; display:block; margin:0 auto; margin-top:30px; font-size:10pt; line-height:150%;">
<span>我们为您提供-
<a href="/html+css/">HTML+CSS模板</a>,
<a href="/js/">JS代码</a>,
<a href="/js/texiao/">网页特效</a>,
for(m=0;;m++)
{
k=(CalendarData[m]<0xfff)?11:12;
for(n=k;n>=0;n--)
{
if(total<=29+GetBit(CalendarData[m],n))
}
function GetDateString()
{
var tmp="";
var t1=TheDate.getYear();
if (t1<1900)t1+=1900;
tmp+=t1
<meta name="description" content="懒人建站为您提供-JS代码,js特效代码大全,js特效广告代码,下拉菜单,下拉菜单代码,导航菜单代码和基于jquery的各种特效与jquery插件。" />
</head>
<body>
<script>
var CalendarData=new Array(20);
CalendarData[17]=0x52B;
CalendarData[18]=0xA93;
CalendarData[19]=0x40E95;
madd[0]=0;
madd[1]=31;
madd[2]=59;
<span>本代码由<a href="" style="color:#F00;">懒人建站网 收集整理 我要学电脑.COM →</a> </span><br>
<a href="/">懒人建站 /</a><br /><br/>
cMonth--;
}
cHour=Math.floor((TheDate.getHours()+3)/2);
}
function GetcDateString()
{ var tmp="";
+"年"
+(TheDate.getMonth()+1)+"月"
+TheDate.getDate()+"日 "
+TheDate.getHours()+":"
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>日期时间带星期农历js代码-懒人建站</title>
<meta name="keywords" content="jquery特效,JS代码,js特效代码大全,js特效广告代码,导航菜单代码" />
tmp+=tgString.charAt((cYear-4)%10); //年干
tmp+=dzString.charAt((cYear-4)%12); //年支
tmp+="年(";
tmp+=sx.charAt((cYear-4)%12);
+((TheDate.getMinutes()<10)?"0":"")
+TheDate.getMinutes()
+" 星期"+weekString.charAt(TheDate.getDay());
CalendarData[2]=0xDA5;
CalendarData[3]=0x20B55;
CalendarData[4]=0x56A;
CalendarData[5]=0x7155B;
CalendarData[6]=0x25D;
日期时间带星期农历js代码特效
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="/1999/xhtml">
DateString=tmp;
return tmp;
}
init();
e2c();
GetDateString();
GetcDateString();
document.write(DateString,"农历",cDateString);
+madd[TheDate.getMonth()]
+TheDate.getDate()
-23;
if (TheDate.getYear()%4==0&&TheDate.getMonth()>1)
total++;
var cDateString;
var DateString;
var Browser=navigator.appName;
function init()
{
CalendarData[0]=0x41A95;
CalendarData[1]=0xD4A;
CalendarData[12]=0xAD5;
CalendarData[13]=0x90AB5;
CalendarData[14]=0x4BA;
CalendarData[15]=0xA5B;
CalendarData[16]=0x60A57;
var isEnd=false;
var tmp=TheDate.getYear();
if (tmp<1900) tmp+=1900;
total=(tmp-2001)*365
+Math.floor((tmp-2001)/4)
tmp+=" ";
if(cHour==13)tmp+="夜";
tmp+=dzString.charAt((cHour-1)%12);
tmp+="时";
cDateString=tmp;
return tmp;
if(cMonth==Math.floor(CalendarData[m]/0x10000)+1)
cMonth=1-cMonth;
if(cMonth>Math.floor(CalendarData[m]/0x10000)+1)
var monString="正二三四五六七八九十冬腊";
var weekString="日一二三四五六";
var sx="鼠牛虎兔龙蛇马羊猴鸡狗猪";
var cYear;
var cMonth;
var cDay;
var cHour;
madd[11]=334;
}
function GetBit(m,n)
{
return (m>>n)&1;
}
function e2c()
{
var total,m,n,k;
var madd=new Array(12);
var TheDate=new Date();
var tgString="甲乙丙丁戊己庚辛壬癸";
var dzString="子丑寅卯辰巳午未申酉戌亥";
var numString="一二三四五六七八九十";
tmp+="月";
tmp+=(cDay<11)?"初":((cDay<20)?"十":((cDay<30)?"廿":"卅"));
if(cDay%10!=0||cDay==10)
tmp+=numString.charAt((cDay-1)%10);
相关文档
最新文档