DatePeriod 类
(PHP 5 >= 5.3.0, PHP 7, PHP 8)
简介
DatePeriod 类表示一个时间周期。
一个时间周期可以用来在给定的一段时间之内, 以一定的时间间隔进行迭代。
类摘要
DatePeriod
implements
Traversable
{
/* 常量 */
/* 属性 */
/* 方法 */
public __construct
( DateTimeInterface
$start
, DateInterval $interval
, int $recurrences
, int $options
= 0
)
public __construct
( DateTimeInterface
}$start
, DateInterval $interval
, DateTimeInterface $end
, int $options
= 0
)预定义常量
DatePeriod::EXCLUDE_START_DATE
-
在 DatePeriod::__construct() 构造函数中使用,表示不包含开始时间。
属性
- recurrences
-
如果通过显式的传入
$recurrences
来创建的 DatePeriod 实例, 那么这个参数表示循环次数。 参见:DatePeriod::getRecurrences()。 - include_start_date
-
在循环过程中,是否包含开始时间。
- start
-
时间周期的开始时间。
- current
-
表示在时间周期内迭代的时候,当前的时间。
- end
-
时间周期的结束时间。
- interval
-
ISO 8601 格式的间隔。
更新日志
版本 | 说明 |
---|---|
5.3.27, 5.4.17 | 公开以下属性:recurrences, include_start_date,start, current,end 和 interval。 |
目录
- DatePeriod::__construct — Creates a new DatePeriod object
- DatePeriod::getDateInterval — Gets the interval
- DatePeriod::getEndDate — Gets the end date
- DatePeriod::getRecurrences — Gets the number of recurrences
- DatePeriod::getStartDate — Gets the start date