显示今天的JS代码(阳历和阴历)的日期。

1。显示日期代码:

JS代码


获取当前日期
功能getcurrentdatetime(){
新日期();
VaR年= d.getfullyear();
VaR月= d.getmonth()+ 1;
var date = d.getdate();
VAR周= d.getday();
当 /
/ *功小时= d.gethours();
VaR分钟= d.getminutes();
VaR秒= d.getseconds();
var = d.getmilliseconds(MS);* /
无功curdatetime =年;
如果(月> 9)
curdatetime = curdatetime +年+月;
其他的
curdatetime = curdatetime +0+月;
如果(日期> 9)
curdatetime = curdatetime +月+日期+天;
其他的
curdatetime = curdatetime +月0+日期+天;
如果(小时> 9)
curdatetime = curdatetime ++小时;
其他的
curdatetime = curdatetime +0+小时;
如果(分钟> 9)
curdatetime = curdatetime +:+分钟;
其他的
curdatetime = curdatetime +:0分钟;
如果(秒> 9)
curdatetime = curdatetime +:+秒;
其他的
curdatetime = curdatetime + 0 +秒;* /
var工作日= ;
如果(星期= 0)
工作日=星期日;
否则如果(星期= 1)
工作日=星期一;
否则如果(星期= 2)
工作日=星期二;
否则如果(星期= 3)
工作日=星期三;
否则如果(星期= 4)
工作日=星期四;
否则如果(星期= 5)
工作日=星期五;
否则如果(星期= 6)
工作日=星期六;
curdatetime = curdatetime ++平日;
返回curdatetime;
}


2。显示农历代码:

JS代码




获取当前日历
功能showcal(){
新日期();
VaR YY = d.getfullyear();
VaR d.getmonth毫米=()+ 1;
var = d.getdate(DD);
VaR WW d.getday();
VaR SS = parseInt()/ D.getTime(1000);
如果(YY 100)YY =19+ YY;
Return GetLunarDay (YY, mm, DD);
}

全局变量的定义
无功calendardata =新阵(100);
VaR MADD =新阵(12);
无功tgstring =甲乙丙丁桂Wuji Xinren Geng;
无功dzstring =巽根本原因不是下午沈海有序;
无功numstring =yiersansiwuliuqibajiushi ;
无功monstring = 是ersansiwuliuqibajiushi冬季蜡;
无功weekstring =123456天;
VaR SX =鼠牛虎兔龙蛇马羊猴鸡犬猪;
无功cyear,cmonth,cday,日期;
calendardata新=阵列(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;

函数中的getbit(m,n){
返回(m×n)1;
}
月球转换
功能E2C(){
日期=(arguments.length!= 3)新日期():新日期(参数{ 0 },参数{ 1 },参数{ 2 });
总、m、n、k;
无功终端= false;
var tmp = thedate.getyear();
如果(TMP<1900){
TMP=1900;
}
总=(tmp-1921)* 365 + math.floor((tmp-1921) / 4)+ thedate.getmonth MADD {()} + thedate.getdate()- 38;

如果(thedate.getyear()% 4 = = 0thedate.getmonth()> 1){
总+;
}
对于(m=0;;m + +){
K =(calendardata {米} < 0xfff)11:12;
对于(n = k;n = 0;n){
如果(总< = 29 +中的getbit(calendardata {米},N)){
终端= true;打破;
}
总= total-29-getbit(calendardata {米},N);
}
如果(终端)打破;
}
cyear = 1921 + M;
cmonth K-N + 1 =;
cday =总;
如果(k=12){
如果(cmonth = = math.floor(calendardata {米} / 0x10000)+ 1){
cmonth = 1-cmonth;
}
如果(cmonth > math.floor(calendardata {米} / 0x10000)+ 1){
cmonth --;
}
}
}

功能getcdatestring(){
var;
显示:农历新年(如:中日(马)年)。
/ *川芎嗪+ = tgstring.charat(((cyear-4)% 10);
川芎嗪+ = dzstring.charat(((cyear-4)% 12);

川芎嗪+ = sx.charat(((cyear-4)% 12);

如果(cmonth<1){
TMP(跳跃);
川芎嗪+ = monstring.charat(- cmonth-1);
其他{ }
Tmp+=monString.charAt (cMonth-1);
}
月;
川芎嗪+ =(cday<11)早:(cday<20)十:((cday<30)二十三十);
如果(cday % 10!= 0 | | cday = = 10){
川芎嗪+ = numstring.charat(((cday-1)% 10);
}
返回TMP;
}

功能getlunarday(solaryear,solarmonth,solarday){
/ / solaryear = solaryear<1900(1900 + solaryear):solaryear;
如果(solaryear2020){
返回;
其他{ }
solarmonth =(parseInt(solarmonth)> 0)(solarmonth-1):11;
E2C(solaryear,solarmonth,solarday);
返回getcdatestring();
}
}


三.显示:

JS代码


$(函数(){())
var date = getcurrentdatetime();
VaR的日历= showcal();
$(# currentdate)。文本(今天是:+日期+农历+日历);
});