Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

dateperiod.__construct(3) [php man page]

DATEPERIOD.__CONSTRUCT(3)						 1						 DATEPERIOD.__CONSTRUCT(3)

DatePeriod::__construct - Creates a new DatePeriod object

SYNOPSIS
public DatePeriod::__construct (DateTimeInterface $start, DateInterval $interval, int $recurrences, [int $options]) DESCRIPTION
DatePeriod::__construct (DateTimeInterface $start, DateInterval $interval, DateTimeInterface $end, [int $options]) DatePeriod::__con- struct (string $isostr, [int $options]) Creates a new DatePeriod object. PARAMETERS
o $start - The start date of the period. o $interval - The interval between recurrences within the period. o $recurrences - The number of recurrences. o $end - The end date of the period. o $isostr - An ISO 8601 repeating interval specification. o $options - Can be set to DatePeriod::EXCLUDE_START_DATE to exclude the start date from the set of recurring dates within the period. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.5.8 | | | | | | | $end type changed to DateTimeImmutable. Previ- | | | ously, DateTime. | | | | | 5.5.0 | | | | | | | $start type changed to DateTimeImmutable. Previ- | | | ously, DateTime. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 DatePeriod example <?php $start = new DateTime('2012-07-01'); $interval = new DateInterval('P7D'); $end = new DateTime('2012-07-31'); $recurrences = 4; $iso = 'R4/2012-07-01T00:00:00Z/P7D'; // All of these periods are equivalent. $period = new DatePeriod($start, $interval, $recurrences); $period = new DatePeriod($start, $interval, $end); $period = new DatePeriod($iso); // By iterating over the DatePeriod object, all of the // recurring dates within that period are printed. foreach ($period as $date) { echo $date->format('Y-m-d')." "; } ?> The above example will output: 2012-07-01 2012-07-08 2012-07-15 2012-07-22 2012-07-29 Example #2 DatePeriod example with DatePeriod::EXCLUDE_START_DATE <?php $start = new DateTime('2012-07-01'); $interval = new DateInterval('P7D'); $end = new DateTime('2012-07-31'); $period = new DatePeriod($start, $interval, $end, DatePeriod::EXCLUDE_START_DATE); // By iterating over the DatePeriod object, all of the // recurring dates within that period are printed. // Note that, in this case, 2012-07-01 is not printed. foreach ($period as $date) { echo $date->format('Y-m-d')." "; } ?> The above example will output: 2012-07-08 2012-07-15 2012-07-22 2012-07-29 PHP Documentation Group DATEPERIOD.__CONSTRUCT(3)

Check Out this Related Man Page

DATETIMEIMMUTABLE(3)							 1						      DATETIMEIMMUTABLE(3)

The DateTimeImmutable class

INTRODUCTION
This class behaves the same as DateTime except it never modifies itself but returns a new object instead. CLASS SYNOPSIS
DateTimeImmutable DateTimeImmutableDateTimeInterface Methods o public DateTimeImmutable::__construct NULL ([string $time = "now"], [DateTimeZone $timezone]) o public DateTimeImmutable DateTimeImmutable::add (DateInterval $interval) o publicstatic DateTimeImmutable DateTimeImmutable::createFromFormat (string $format, string $time, [DateTimeZone $timezone]) o publicstatic DateTimeImmutable DateTimeImmutable::createFromMutable (DateTime $datetime) o publicstatic array DateTimeImmutable::getLastErrors (void ) o public DateTimeImmutable DateTimeImmutable::modify (string $modify) o publicstatic DateTimeImmutable DateTimeImmutable::__set_state (array $array) o public DateTimeImmutable DateTimeImmutable::setDate (int $year, int $month, int $day) o public DateTimeImmutable DateTimeImmutable::setISODate (int $year, int $week, [int $day = 1]) o public DateTimeImmutable DateTimeImmutable::setTime (int $hour, int $minute, [int $second]) o public DateTimeImmutable DateTimeImmutable::setTimestamp (int $unixtimestamp) o public DateTimeImmutable DateTimeImmutable::setTimezone (DateTimeZone $timezone) o public DateTimeImmutable DateTimeImmutable::sub (DateInterval $interval) o public DateInterval DateTimeImmutable::diff (DateTimeInterface $datetime2, [bool $absolute = false]) o public string DateTimeImmutable::format (string $format) o public int DateTimeImmutable::getOffset (void ) o public int DateTimeImmutable::getTimestamp (void ) o public DateTimeZone DateTimeImmutable::getTimezone (void ) o public DateTimeImmutable::__wakeup (void ) PHP Documentation Group DATETIMEIMMUTABLE(3)
Man Page