檢視當前日期的農曆日期的JS

2021-04-22 11:41:03 字數 1846 閱讀 2222

預覽效果:2023年11月28日 星期五 農曆戊子年 冬月初一

js 檔案如下:today.js

function runglnl()

function daysnumberofdate(dategl)

function ***ateofdate(dategl)

bytes[0] = ***ata[(yyyy - 1997) * 4];

bytes[1] = ***ata[(yyyy - 1997) * 4 + 1];

bytes[2] = ***ata[(yyyy - 1997) * 4 + 2];

bytes[3] = ***ata[(yyyy - 1997) * 4 + 3];

if ((bytes[0] & 0x80) != 0)

else

cnbeginday = (bytes[0] & 0x7f);

cnmonthdata = bytes[1];

cnmonthdata = cnmonthdata << 8;

cnmonthdata = cnmonthdata | bytes[2];

leapmonth = bytes[3];

for (i=15;i>=0;i--)

if (cnmonth[15 - i] == leapmonth )

else

else

if (cnmonth[15 - i + 1] > 12 )}}

dayscount = daysnumberofdate(dategl) - 1;

if (dayscount <= (cnmonthdays[0] - cnbeginday))

else

resultday = cnbeginday + dayscount;

}else

resultmonth = cnmonth[i];

resultday = dayscount - ***ayscount;

}if (resultmonth > 0)

else

}function cnyearofdate(dategl)

function cnmonthofdate(dategl)

else

}function ***ayofdate(dategl)

function daysnumberofmonth(dategl)

function cnera(yyyy)

function ***ateofdatestr(dategl)

function solarterm(dategl)

for(var m=0;dategl.getmonth()>begintime.getmonth();m++)

if(dategl.getdate()>begintime.getdate())

if(dategl.getdate()>begintime.getdate())

var jq;

if(dategl.getdate()==begintime.getdate())

else if(dategl.getdate()==begintime.getdate()-1)

else if(dategl.getdate()==begintime.getdate()-2)

else

else

jq+=begintime.getdate()+"日"+""+solartermstr[m]+"";

}return jq;

}function cal()

{}runglnl();

function curenttime()

使用的時候儲存改js,然後在需要顯示日期的地方使用下面的語句(請自己修改位址)

獲得當前日期 農曆日期及生肖

region 農曆 節氣 類 public class chinacalendar region 方法主體 預設系統當前日期 private datetime dtvalue convert.todatetime datetime.now.toshortdatestring 用來計算農曆的初始日期 ...

js獲取當前日期

1.date 物件用於處理日期和時間。建立 date 物件的語法 var mydate new date date 物件會自動把當前日期和時間儲存為其初始值。2.引數形式有以下5種 new date month dd,yyyy hh mm ss new date month dd,yyyy new ...

JS日期,JS獲取當前日期時間,js日期格式化

var mydate new date mydate.getyear 獲取當前年份 2位 mydate.getfullyear 獲取完整的年份 4位,1970 mydate.getmonth 獲取當前月份 0 11,0代表1月 注意別忘了 1 mydate.getdate 獲取當前日 1 31 my...