Tom*_*ird 16 php datetime iterator
我理解日期是如何工作的,有一个例外,有没有办法从日期周期中找出有多少个区间?
例如:
// define the period of the range
$period = new DatePeriod($begin, $rangeType, $end);
// iterate through the dates in range
foreach ( $period as $dt ) {
}
Run Code Online (Sandbox Code Playgroud)
这是我想从上面的代码做的事情:
echo count($period);
Run Code Online (Sandbox Code Playgroud)
基本上我想知道foreach循环结束运行的时间.
Div*_*com 31
您可以使用此iterator_count功能:
echo(iterator_count($period));
Run Code Online (Sandbox Code Playgroud)