La clase DatePeriod

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

Introducción

Representa un período de fechas.

Un período de fechas permite la iteración sobre un conjunto de fechas y horas, repitiéndose a intervalos regulares durante un período dado.

Sinopsis de la Clase

class DatePeriod implements Traversable {
/* Constantes */
const integer EXCLUDE_START_DATE = 1;
/* Propiedades */
public integer $recurrences;
public boolean $include_start_date;
/* Métodos */
public __construct(
    DateTimeInterface $start,
    DateInterval $interval,
    int $recurrences,
    int $options = ?
)
public __construct(
    DateTimeInterface $start,
    DateInterval $interval,
    DateTimeInterface $end,
    int $options = ?
)
public __construct(string $isostr, int $options = ?)
public getRecurrences(): ?int
}

Constantes predefinidas

DatePeriod::EXCLUDE_START_DATE

Excluir la fecha inicial, usado en DatePeriod::__construct().

Propiedades

recurrences

include_start_date

start

current

end

interval

Tabla de contenidos

add a note

User Contributed Notes 1 note

up
20
mail at pascalhofmann dot de
5 years ago
When looping over a DatePeriod object, the returned objects always implement DateTimeInterface. The exact type returned depends on how the DatePeriod was created. If $start was a DateTimeImmutable, the objects returned will be of type DateTimeImmutable. If a DateTime object was used, the objects returned will be of type DateTime.
To Top