本文整理汇总了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();
}