(PHP 5 >= 5.3.0, PHP 7)
简介
DatePeriod 类表示一个时间周期。
一个时间周期可以用来在给定的一段时间之内,
以一定的时间间隔进行迭代。
类摘要
DatePeriod
implements
Traversable
{
/* 常量 */
const
integer
EXCLUDE_START_DATE
= 1
;
/* 属性 */
public
integer
$recurrences
;
public
boolean
$include_start_date
;
public
[DateTimeInterface](php7/class.datetimeinterface)
$start
;
public
[DateTimeInterface](php7/class.datetimeinterface)
$current
;
public
[DateTimeInterface](php7/class.datetimeinterface)
$end
;
public
[DateInterval](php7/class.dateinterval)
$interval
;
/* 方法 */
public [__construct](php7/dateperiod.construct)
( [DateTimeInterface](php7/class.datetimeinterface) $start
, [DateInterval](php7/class.dateinterval) $interval
, int $recurrences
[, int $options
] )
public [__construct](php7/dateperiod.construct)
( [DateTimeInterface](php7/class.datetimeinterface) $start
, [DateInterval](php7/class.dateinterval) $interval
, [DateTimeInterface](php7/class.datetimeinterface) $end
[, int $options
] )
public [__construct](php7/dateperiod.construct)
( string $isostr
[, int $options
] )
public [getDateInterval](php7/dateperiod.getdateinterval)
( void
) : [DateInterval](php7/class.dateinterval)
public [getEndDate](php7/dateperiod.getenddate)
( void
) : [DateTimeInterface](php7/class.datetimeinterface)
public [getStartDate](php7/dateperiod.getstartdate)
( void
) : [DateTimeInterface](php7/class.datetimeinterface)
}
预定义常量
DatePeriod::EXCLUDE_START_DATE
在 [DatePeriod::__construct()](php7/dateperiod.construct) 构造函数中使用,表示不包含开始时间。
属性
recurrences
循环次数。
include_start_date
在循环过程中,是否包含开始时间。
start
时间周期的开始时间。
current
表示在时间周期内迭代的时候,当前的时间。
end
时间周期的结束时间。
interval
ISO 8601 格式的间隔。
更新日志
版本
说明
5.3.27, 5.4.17
公开以下属性:recurrences,
include_start_date,start,
current,end 和
interval。
Table of Contents
DatePeriod::__construct — Creates a new DatePeriod object
DatePeriod::getDateInterval — Gets the interval
DatePeriod::getEndDate — Gets the end date
DatePeriod::getStartDate — Gets the start date
本文介绍了PHP中的DatePeriod类,该类用于表示一个时间周期,并能在给定的时间段内以固定的时间间隔进行迭代。文章详细解释了DatePeriod类的构造方法及如何获取时间间隔、开始时间和结束时间。
6252

被折叠的 条评论
为什么被折叠?



