formatDuration
返回以人类可读形式描述的持续时间字符串。
javascript
import { formatDuration } from "date-fns";
// 格式化持续时间
const duration = formatDuration({
years: 1,
months: 3,
days: 2,
hours: 4,
minutes: 30,
seconds: 15,
});
console.log(`持续时间为:${duration}`); // 持续时间为:1 year, 3 months, 2 days, 4 hours, 30 minutes, 15 seconds