DatePeriod 類(lèi)

(PHP 5 >= 5.3.0, PHP 7, PHP 8)

簡(jiǎn)介

DatePeriod 類(lèi)表示一個(gè)時(shí)間周期。

一個(gè)時(shí)間周期可以用來(lái)在給定的一段時(shí)間之內(nèi), 以一定的時(shí)間間隔進(jìn)行迭代。

類(lèi)摘要

class DatePeriod implements Traversable {
/* 常量 */
const integer EXCLUDE_START_DATE = 1;
/* 屬性 */
public integer $recurrences;
public boolean $include_start_date;
/* 方法 */
public __construct(
    DateTimeInterface $start,
    DateInterval $interval,
    int $recurrences,
    int $options = 0
)
public __construct(
    DateTimeInterface $start,
    DateInterval $interval,
    DateTimeInterface $end,
    int $options = 0
)
public __construct(string $isostr, int $options = 0)
public getRecurrences(): ?int
}

預(yù)定義常量

DatePeriod::EXCLUDE_START_DATE

DatePeriod::__construct() 構(gòu)造函數(shù)中使用,表示不包含開(kāi)始時(shí)間。

屬性

recurrences

如果通過(guò)顯式的傳入 $recurrences 來(lái)創(chuàng)建的 DatePeriod 實(shí)例, 那么這個(gè)參數(shù)表示循環(huán)次數(shù)。 參見(jiàn):DatePeriod::getRecurrences()

include_start_date

在循環(huán)過(guò)程中,是否包含開(kāi)始時(shí)間。

start

時(shí)間周期的開(kāi)始時(shí)間。

current

表示在時(shí)間周期內(nèi)迭代的時(shí)候,當(dāng)前的時(shí)間。

end

時(shí)間周期的結(jié)束時(shí)間。

interval

ISO 8601 格式的間隔。

更新日志

版本 說(shuō)明
5.3.27, 5.4.17 公開(kāi)以下屬性:recurrences, include_start_datestart, currentendinterval。

目錄