JavaScript shows time date and lunar code

Source: Internet
Author: User
Tags getdate
Tip: You can modify some of the code before running

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "> <pead> <meta http-equiv=" Content-type "Conten T= "text/html; charset=gb2312 "/> <title>javascript get now time date with lunar </title> <script language=" JavaScript "> VA R Sweek = new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); var dnow = new Date (); var calendardata = new Array (100); var madd = new Array (12); var tgstring = "Methyl ethyl propionate Xing"; var dzstring = "Kaniko chen has not Shin Hai"; var numstring = "1,234,567,890"; var monstring = "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, 0xE A5, 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, 0xA4 D, 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, 0xDA 5, 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 <= + getbit (calendardata[m], n)) {isend = true; -Getbit (Calendardata[m], n); } if (isend) break; } cyear = 1921 + M; Cmonth = k-n + 1; Cday = total; if (k = =) {if (Cmonth = = Math.floor (calendardata[m]/0x10000) + 1) {cmonth = 1-cmonth;} if (Cmonth > Math.floo R (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)? "Beginning": ((Cday < 20)? "Ten": ((Cday < 30)? "20": "30")); if (cday%!= 0 | | | cday = =) {tmp + = Numstring.charat ((cDay-1)%);} return tmp; function Getlunarday (solaryear, Solarmonth, Solarday) {if (Solaryear < 1921 | | solaryear > 2020) {RE Turn ""; 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 () {timestring = new Date (). tolocaletimestring (); var svalue = getFullYear (dnow) + "year" + (Dnow.getmonth () + 1) + "month" + dnow.getdate () + "Day" + "" + TimeString + "" + sweek[dnow.getday ()] + ""; svalue + + = Getlunarday (yy, MM, DD); var svalue1 = getFullYear (dnow) + "year" + (Dnow.getmonth () + 1) + "month" + dnow.getdate () + "Day" + Sweek[dnow.getday ()]; var svalue2 = timestring; var svalue3 = Getlunarday (yy, MM, DD); var sx2 = Sx.substr (Dzstring.indexof (SVALUE3.SUBSTR (1, 1)), 1); var svalue33 = svalue3.substr (0, 3) var svalue333 = svalue33.substr (0, 2) + "(" + SX2 + ")" + SVALUE33.SUBSTR (2, 1); var sx22 = "Lunar" + svalue3.substr (4, 6); document.getElementById (' Nowdateis '). InnerHTML = svalue1 document.getElementById (' Nowcnyearis '). InnerHTML = svalue333 + sx22; }; document.write ("<table border= ' 0 ' cellspacing= ' 0 ' width= ') ' height= ' cellpadding= ' 0 ' >"); document.write ("<tr><td align= ' center ' ><b><font color= #008040 ><span id= ' nowDateIs ' > </span></font><br/><font face= ' Arial ' color= #FF8040 ><span id= ' Nowcnyearis ' ></ span></font></td></tr></table> "); </script> </pead> <body><script language= "JavaScript" >showdate ();</script> </ body> </ptml> </td> </tr> </table>
Tip: You can modify some of the code before running
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.