教程 date-fns tutorial

yearsToMonths

将年数转换为月数。

javascript
import { yearsToMonths } from "date-fns";

// 示例年数
const years = 2;

// 将年数转换为月数
const months = yearsToMonths(years);

console.log("转换后的月数:", months); // 转换后的月数:24