本文整理汇总了PHP中Grav\Common\Utils::date2timestamp方法的典型用法代码示例。如果您正苦于以下问题:PHP Utils::date2timestamp方法的具体用法?PHP Utils::date2timestamp怎么用?PHP Utils::date2timestamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Grav\Common\Utils
的用法示例。
在下文中一共展示了Utils::date2timestamp方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: date
/**
* Gets and sets the date for this Page object. This is typically passed in via the page headers
*
* @param string $var string representation of a date
* @return int unix timestamp representation of the date
*/
public function date($var = null)
{
if ($var !== null) {
$this->date = Utils::date2timestamp($var);
}
if (!$this->date) {
$this->date = $this->modified;
}
return $this->date;
}
示例2: dateRange
/**
* Returns the items between a set of date ranges of either the page date field (default) or
* an arbitrary datetime page field where end date is optional
* Dates can be passed in as text that strtotime() can process
* http://php.net/manual/en/function.strtotime.php
*
* @param $startDate
* @param bool $endDate
* @param $field
*
* @return $this
* @throws \Exception
*/
public function dateRange($startDate, $endDate = false, $field = false)
{
$start = Utils::date2timestamp($startDate);
$end = $endDate ? Utils::date2timestamp($endDate) : strtotime("now +1000 years");
$date_range = [];
foreach ($this->items as $path => $slug) {
$page = $this->pages->get($path);
$date = $field ? strtotime($page->value($field)) : $page->date();
if ($date > $start && $date < $end) {
$date_range[$path] = $slug;
}
}
$this->items = $date_range;
return $this;
}
示例3: testDate2timestamp
public function testDate2timestamp()
{
$timestamp = strtotime('10 September 2000');
$this->assertSame($timestamp, Utils::date2timestamp('10 September 2000'));
$this->assertSame($timestamp, Utils::date2timestamp('2000-09-10 00:00:00'));
}