安装插件
cnpm install js-calendar-converter --S
导入插件
import calendar_converter from 'js-calendar-converter'
农历日期转公历日期
let new_date = calendar_converter.lunar2solar(2023, 12, 01) let new_year = new_date.cYear let new_month = new_date.cMonth < 10 ? ('0' + new_date.cMonth) : new_date.cMonth let new_day = new_date.cDay < 10 ? ('0' + new_date.cDay) : new_date.cDay console.log('公历日期为:', new_year + new_month + new_day)
得到公历日期 20240111
更多属性和方法见
https://blog.csdn.net/weixin_51157081/article/details/131285709