From: http://www.cnblogs.com/Gnepner/archive/2011/09/07/2169822.html
Get Current date Gettoday.js:
functionGetCurrentDateTime () {varD =NewDate (); varYear =d.getfullyear (); varmonth = D.getmonth () + 1; varDate =d.getdate (); varWeek =D.getday (); varHours =d.gethours (); varminutes =d.getminutes (); varseconds =d.getseconds (); varms =d.getmilliseconds (); varCurdatetime =Year ; if(Month > 9) Curdatetime= Curdatetime + "Year" +month; ElseCurdatetime= Curdatetime + "Year 0" +month; if(Date > 9) Curdatetime= Curdatetime + "Month" + Date + "Day"; ElseCurdatetime= curdatetime + "Month 0" + Date + "Day"; if(Hours > 9) Curdatetime= Curdatetime + "" +hours; ElseCurdatetime= Curdatetime + "0" +hours; if(Minutes > 9) Curdatetime= Curdatetime + ":" +minutes; ElseCurdatetime= Curdatetime + ": 0" +minutes; if(Seconds > 9) Curdatetime= Curdatetime + ":" +seconds; ElseCurdatetime= Curdatetime + ": 0" +seconds; varWeekday = ""; 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; returnCurdatetime;}
Get the lunar getcndate.js of the day
varCalendarData =NewArray (100);varMADD =NewArray (12);varTgstring = "Methyl-N-propyl-Xing";vardzstring = "obscure chen Shin hai";varnumstring = "1,234,567,890";varmonstring = "Just 234,567,890 winter Wax";varweekstring = "Day 123456";varSX = "Mouse cow tiger rabbit dragon snake horse sheep monkey chicken Dog Pig";varcyear, Cmonth, Cday, thedate; CalendarData=NewArray (0xa4b, 0x5164b, 0x6a5, 0x6d4, 0x415b5, 0x2b6, 0x957, 0x2092f, 0x497, 0x60c96, 0xd4a, 0xea5, 0x50da9, 0x5AD, 0x2B6, 0 x3126e, 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, 0xD9 5, 0x70b55, 0x56a, 0x96d, 0x5095d, 0X4AD, 0xa4d, 0x41a4d, 0xd25, 0x81aa5, 0xb54, 0xb6a, 0x612da, 0x95b, 0x49B, 0x41497, 0x A4B, 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;functionGetbit (M, n) {return(M >> N) & 1;}functione2c () {thedate= (Arguments.length! = 3)?NewDate ():NewDate (Arguments[0], arguments[1], arguments[2]); varTotal , M, N, K; varIsend =false; varTMP =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--; } }}functiongetcdatestring () {varTMP = ""; 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)? "Beginning": ((Cday < 20)? "Ten": ((Cday < 30)? "20": "30")); if(cday%! = 0 | | cday = = 10) {tmp+ = Numstring.charat ((cDay-1)% 10); } returntmp;}functionGetlunarday (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); returngetcdatestring (); }}varBNewDate ();varyy =d.getfullyear ();varmm = D.getmonth () + 1;varDD =d.getdate ();varWW =D.getday ();varSS = parseint (D.gettime ()/1000);if(yy < +) yy = "19" +yy;functiongetcndate () {returnGetlunarday (yy, MM, DD);}
Report:
Http://files.cnblogs.com/Gnepner/GetCNDate.js
Http://files.cnblogs.com/Gnepner/GetToday.js
Get the current date and the JS code of the lunar calendar