This article for you to share a section of JS display the lunar calendar (lunar calendar) and the current date of the key code for your reference, the specific content as follows
var calendardata=new Array (100);
var madd=new Array (12);
var tgstring= "A B-n-butyl Xing";
var dzstring= "Kaniko Chen has not Shin Hai";
var numstring= "1,234,567,890";
var monstring= "is 234,567,890 winter wax";
var weekstring= "Day 123456";
var sx= "Mouse cow tiger rabbit snake horse sheep monkey chicken Dog pig";
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,0x71695, 0x6ca,0xb55,0x50ab5,0x4da,0xa5b,0x30a57,0x52b,0x8152a,0xe95,0x6aa,0x615aa,0xab5,0x4b6,0x414ae,0xa57,0x526, 0x31d26,0xd95,0x70b55,0x56a,0x96d,0x5095d,0x4ad,0xa4d,0x41a4d,0xd25,0x81aa5,0xb54,0xb6a,0x612da,0x95b,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.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;
} 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+= ") year"; if (cmonth<1) {tmp+= "(Leap)"; Tmp+=monstring.charat (-cmonth-1);}
else{Tmp+=monstring.charat (cMonth-1);} tmp+= "Month"; tmp+= (cday<11)? " The first ":((cday<20)?" Ten ":((cday<30)?"
20 ":" 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= "+yy"; function showcal () {document.write (Getlunarday (YY,MM,DD));}
Page Call Code:
<script language= "JavaScript" type= "Text/javascript" src= "getcndate.js" ></script>
<script type= "Text/javascript" >showcal ();</script>
Code two: get the current lunar date with JavaScript
<script type= "Text/javascript" > var sweek = new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
var dnow = new Date (); var calendardata=new array (MB); var madd=new array (); var tgstring= "Methyl ethyl propionate Xing"; var dzstring= "Kaniko-chen has not Shin Hai"; var Numstring= "1,234,567,890"; var monstring= "Positive 234,567,890 winter Wax"; var weekstring= "Day 123456"; var sx= "rat bovine tiger rabbit snake horse sheep monkey chicken Dog pig"; var cyear,
Cmonth,cday,thedate; CalendarData = new Array (0xa4b,0x5164b,0x6a5,0x6d4,0x415b5,0x2b6,0x957,0x2092f,0x497,0x60c96, 0xD4A,0xEA 5,0x50da9,0x5ad,0x2b6,0x3126e, 0x92e,0x7192d,0xc95,0xd4a, 0x61b4a,0xb55,0x56a,0x4155b, 0x25D,0x92D,0x2192B,0xA9 5,0x71695,0x6ca, 0XB55,0X50AB5,0X4DA,0XA5B,0X30A57,0X52B,0X8152A,0XE95,0X6AA,0X615AA, 0xAB5,0x4B6,0x414 AE,0XA57,0X526,0X31D26,0XD95,0X70B55,0X56A,0X96D, 0x5095d,0x4ad,0xa4d,0x41a4d,0xd25,0x81aa5, 0xB54,0xB6A,0x612DA , 0x95b, 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 Da
Te (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 (calendardata[m],n)) {isend=true; } 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+= "Year"; if (cmonth<1) {tmp+= (LEAP); Tmp+=monstring.charat (-cmonth-1);} else {Tmp+=monstring.charat (cMonth-1);} tmp+= "Month"; tmp+= (cday<11)? " The first ":((cday<20)?" Ten ":((cday<30)?"
20 ":" 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) {//fix Firefox next year error yr=d.getyear (); if (yr<1000) Yr+=1900;return yr;} function Showdate () {var svalue = getFullYear (dnow) + "year" + (Dnow.getmonth () +1) + "month" +dnow.getdate () + "Day" + "" +sweek[
Dnow.getday ()]+ "";
Svalue+=getlunarday (YY,MM,DD);
document.getElementById ("Pdate"). InnerHTML = svalue;
};
Window.onload=showdate;
</script>
Know how to get the lunar calendar, how to get the current date is also very simple.
function GetCurrentDateTime () {var d = new Date ();
var year = D.getfullyear ();
var month = D.getmonth () + 1;
var date = D.getdate ();
var week = D.getday ();
var hours = d.gethours ();
var minutes = d.getminutes ();
var seconds = d.getseconds ();
var ms = D.getmilliseconds ();
var curdatetime = year;
if (Month > 9) curdatetime = Curdatetime + "year" + month;
else Curdatetime = curdatetime + "Year 0" + month;
if (Date > 9) curdatetime = Curdatetime + "Month" + Date + "Day";
else Curdatetime = curdatetime + "Month 0" + Date + "Day";
if (Hours > 9) curdatetime = Curdatetime + "" + hours;
else Curdatetime = Curdatetime + "0" + hours;
if (Minutes > 9) curdatetime = Curdatetime + ":" + minutes;
else Curdatetime = curdatetime + ": 0" + minutes;
if (Seconds > 9) curdatetime = Curdatetime + ":" + seconds;
else Curdatetime = curdatetime + ": 0" + seconds;
var weekday = "";
if (week = = 0) weekday = "Sunday"; else if (weEk = = 1) weekday = "Monday";
else if (week = 2) weekday = "Tuesday";
else if (week = 3) weekday = "Wednesday";
else if (week = 4) weekday = "Thursday";
else if (week = 5) weekday = "Friday";
else if (week = 6) weekday = "Saturday";
Curdatetime = Curdatetime + "" + weekday;
return curdatetime; }
Page Call Code:
<script language= "JavaScript" type= "Text/javascript" src= "Gettoday.js" ></script>
I hope this article on the use of JS code to get the lunar calendar (lunar calendar) has helped, hang on to collect it!