本文整理匯總了PHP中DateTime::timestamp方法的典型用法代碼示例。如果您正苦於以下問題:PHP DateTime::timestamp方法的具體用法?PHP DateTime::timestamp怎麽用?PHP DateTime::timestamp使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DateTime
的用法示例。
在下文中一共展示了DateTime::timestamp方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
/**
* Create a new range from 2 dates.
*
* @param DateTime $start The start date of the range
* @param DateTime $end The end date of the range
*/
public function __construct(DateTime $start, DateTime $end)
{
$this->start = $start;
$this->end = $end;
if ($this->end->timestamp() < $this->start->timestamp()) {
throw new \InvalidArgumentException("Invalid range, the start date must be before the end date");
}
}
示例2: __construct
/**
* Create a new instance from a date object.
*
* @param DateTime $date A date within the season
*/
public function __construct(DateTime $date)
{
$this->unix = $date->timestamp();
$start = Date::mkdate($date->numeric("Y"), $date->numeric("n"), 1);
$end = Date::mkdate($date->numeric("Y"), $date->numeric("n"), $date->numeric("t"));
parent::__construct($start, $end);
}
示例3: equals
/**
* @param DateTime $another
* @return bool
*/
public function equals(DateTime $another)
{
return $this->timestamp() === $another->timestamp();
}