本文整理汇总了PHP中Nette\Utils\DateTime::setDate方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTime::setDate方法的具体用法?PHP DateTime::setDate怎么用?PHP DateTime::setDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Utils\DateTime
的用法示例。
在下文中一共展示了DateTime::setDate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDefaultParser
protected function getDefaultParser()
{
return function ($value) {
if (!preg_match('#^(?P<dd>\\d{1,2})[. -] *(?P<mm>\\d{1,2})([. -] *(?P<yyyy>\\d{4})?)?$#', $value, $matches)) {
return NULL;
}
$dd = $matches['dd'];
$mm = $matches['mm'];
$yyyy = isset($matches['yyyy']) ? $matches['yyyy'] : date('Y');
if (!checkdate($mm, $dd, $yyyy)) {
return NULL;
}
$value = new Nette\Utils\DateTime();
$value->setDate($yyyy, $mm, $dd);
$value->setTime(0, 0, 0);
return $value;
};
}
示例2: getDefaultParser
protected function getDefaultParser()
{
return function ($value) {
if (!preg_match('#^(?P<dd>\\d{1,2})[. -] *(?P<mm>\\d{1,2})(?:[. -] *(?P<yyyy>\\d{4})?)?(?: *[ -@] *(?P<hh>\\d{1,2})[:.](?P<ii>\\d{1,2})(?:[:.](?P<ss>\\d{1,2}))?)?$#', $value, $matches)) {
return NULL;
}
$dd = $matches['dd'];
$mm = $matches['mm'];
$yyyy = isset($matches['yyyy']) ? $matches['yyyy'] : date('Y');
$hh = isset($matches['hh']) ? $matches['hh'] : 0;
$ii = isset($matches['ii']) ? $matches['ii'] : 0;
$ss = isset($matches['ss']) ? $matches['ss'] : 0;
if (!($hh >= 0 && $hh < 24 && $ii >= 0 && $ii <= 59 && $ss >= 0 && $ss <= 59)) {
$hh = $ii = $ss = 0;
}
if (!checkdate($mm, $dd, $yyyy)) {
return NULL;
}
$value = new Nette\Utils\DateTime();
$value->setDate($yyyy, $mm, $dd);
$value->setTime($hh, $ii, $ss);
return $value;
};
}
示例3: getForDate
public function getForDate($year, $month, $day, array $modifier = [])
{
$abbr = null;
$date = new DateTime();
$date->setDate($year, $month, $day);
if (!empty($modifier) && isset($modifier["abbr"])) {
$abbr = $modifier["abbr"];
}
try {
$qb = $this->eventDao->createQueryBuilder("e");
if ($abbr !== null) {
// $qb->from('App\Model\Entities\Event', 'e')
$qb->join("e.groups", "g")->where("g.abbr = :abbr")->setParameter("abbr", $abbr);
}
$qq = $qb->andWhere("e.takePlaceSince <= :now")->andWhere("e.takePlaceTill >= :now")->setParameter("now", $date)->getQuery();
$res = $qq->getResult();
return $res;
} catch (\Exception $ex) {
$this->logError($ex->getMessage());
throw new Exceptions\DataErrorException($ex->getMessage(), $ex->getCode(), $ex->getPrevious());
}
}
示例4: actionShowEventDay
/**
* @Secured(resource="showEventDay")
*/
public function actionShowEventDay($year, $month, $day)
{
try {
$data = $this->eventService->getForDate($year, $month, $day);
$date = new DateTime();
$date->setDate($year, $month, $day);
$this->template->date = $date->format(self::DATE_FORMAT);
$this->template->data = $data;
} catch (Exceptions\DataErrorException $ex) {
$this->handleDataLoad(null, "this", $ex);
}
}