获取日期范围内的闰日数量

Getting the amount of leap days in a date range

我有以下 2 个日期:

$start = new DateTime('2008-06-01');
$end = new DateTime('2016-12-31');
$diff = $start->diff($end);

现在 $diff->days 给出 3135 days,但这包括 2 个 闰日 。 我应该如何计算 $start$end 日期之间的 2 月 29 日的数量?

这适用于发票系统,其中不应计算闰日(公司政策)

您可以查看是否是闰年:

this other question 和这个之间的唯一区别是,在他们使用 $year 的地方,您编写了一个循环,其中 $i 从您要开始的年份开始,到结束年份结束 (: