CascadiaPHP 2024

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 */
/* Propiedades */
/* 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 static createFromISO8601String(string $specification, int $options = 0): static
}

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
23
mail at pascalhofmann dot de
7 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