js获取农历日期、节气等信息的插件–solarlunar
https://github.com/yize/solarlunar#readme 点我直达
npm install solarlunar // 安装
import solarlunar from 'solarlunar' // 注意是小写的
const nowDate = new Date()
const data = solarlunar.solar2lunar( nowDate.getFullYear(), nowDate.getMonth() + 1, nowDate.getDate()) // 时间戳不支持-1
console.log(data)
/*
{
animal: "兔", // 生肖
cDay: 23, // 公历日
cMonth: 4, // 公历月
cYear: 2023, // 公历年
dayCn: "初四", // 农历月
gzDay: "辛亥", // 日的农历
gzMonth: "丙辰", // 月的农历
gzYear: "癸卯", // 年的农历
isLeap: false, // 是否是闰月
isTerm: false, // 是否有节气
isToday: true, // 是否是今天
lDay: 4, // 农历日
lMonth: 3, // 农历月
lYear: 2023, // 农历年
monthCn: "三月", // 农历月
nWeek: 7, // 星期几
ncWeek: "星期日",// 星期几
term: "", // 节气
yearCn: "二零二三年" // 农历年
}
*/