本文整理汇总了PHP中Nette\Utils\DateTime::format方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTime::format方法的具体用法?PHP DateTime::format怎么用?PHP DateTime::format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Utils\DateTime
的用法示例。
在下文中一共展示了DateTime::format方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: distributionPlanIsCreated
public function distributionPlanIsCreated()
{
$date = new DateTime();
$from = '"' . $date->format('Y.m.d') . ' 00:00:00"';
$to = '"' . $date->format('Y.m.d') . ' 23:59:00"';
$data = $this->db->select('*')->from($this->table)->where('date>' . $from . ' AND date<' . $to)->fetchAll();
if (isset($data[0])) {
return true;
}
return false;
}
示例2: create
/**
* @param \App\Model\Entities\Article|NULL $article Clanek k editaci
* @return Form
*/
public function create($article = NULL, $tags = [])
{
$form = $this->baseFormFactory->create();
$form->addText('title', 'system.postName')->setRequired($form->getTranslator()->translate('system.requiredItem', ['label' => '%label']));
$form->addText('description', 'system.postDescription')->setRequired($form->getTranslator()->translate('system.requiredItem', ['label' => '%label']));
$form->addCheckbox('published', 'system.isPublished');
//chybi publish_date - datum zverejneni
$today = new DateTime();
$form->addText('publishDate', 'system.published')->setType('datetime-local')->setDefaultValue($today->format('d. m. Y, H:i'));
//->setAttribute('placeholder', 'd. m. Y, H:i (den. měsíc. rok');
$form->addMultiSelect('tags', new Phrase('system.tag', 2))->setItems($tags);
$form->addUpload('image', 'system.postImage')->addCondition(Form::FILLED)->addRule(Form::IMAGE, $form->getTranslator()->translate('system.formImage', ['item' => '%label']));
$form->addText('imageSource', 'system.postImageSource');
$form->addTextArea('content', 'system.postContent')->setRequired($form->getTranslator()->translate('system.requiredItem', ['label' => '%label']))->setAttribute('rows', 10);
$form->addSubmit('send', 'system.save');
//id, vychozi hodnoty pri editaci
$form->addHidden('id');
if ($article !== NULL) {
$defaults = $this->getDefaults($article);
$form->setDefaults($defaults);
}
$form->onValidate[] = [$this, 'validateForm'];
$form->onSuccess[] = [$this, 'formSucceeded'];
return $form;
}
示例3: create
/**
* @param array $types
* @param \App\Model\Entities\Vote $vote
* @return Form
*/
public function create($types, $vote = NULL)
{
$form = $this->baseFormFactory->create();
$form->addText('question', 'system.voteQuestion')->setRequired($form->getTranslator()->translate('system.requiredItem', ['label' => '%label']));
$form->addSelect('type', 'system.voteType')->setItems($types)->setPrompt('Zvolte typ dotazu')->setRequired($form->getTranslator()->translate('system.requiredItem', ['label' => '%label']));
$form->addText('expiration', 'system.voteExpiration')->setType('datetime-local')->setAttribute('placeholder', 'd. m. Y, H:i (den. měsíc. rok, hodina:minuta');
$options = $form->addDynamic('options', function (Container $option) {
$option->addText('option', 'system.voteOption');
$option->addSubmit('remove', 'system.delete')->addRemoveOnClick();
}, 1);
$options->addSubmit('add', 'system.new')->setValidationScope(FALSE)->addCreateOnClick();
$form->addSubmit('send', 'system.save');
$form->addHidden('id');
if ($vote) {
$defaults = $this->getDefaults($vote);
$form->setDefaults($defaults);
$options->setValues($defaults['options']);
} else {
$today = new DateTime();
$today->modify('+6 month');
$default = ['expiration' => $today->format(self::$dateMask)];
$form->setDefaults($default);
}
$form->onValidate[] = [$this, 'validateForm'];
$form->onSuccess[] = [$this, 'formSucceeded'];
return $form;
}
示例4: generate
/**
* Generate table
*/
protected function generate()
{
$days = $this->getSpecificDays();
$table = new Table\Sheet();
$line = new Table\Line();
$lastTimeFrom = NULL;
$lastTimeTo = NULL;
$lastDay = NULL;
$lastTags = NULL;
$now = new DateTime();
foreach ($days as $day) {
$timeFrom = (new FilterTime\Def($day->openTime))->output;
$timeTo = (new FilterTime\Def($day->closeTime))->output;
if ($lastTimeFrom === $timeFrom && $lastTimeTo === $timeTo && $this->tagsAreSame($lastTags, $day->tags) && $lastDay !== NULL && (int) $lastDay->day->diff($day->day)->format('%r%a') === 1) {
$line->dateTo = $day->day;
} else {
$lastTimeTo !== NULL && $table->addLine($line);
$line = new Table\Line();
$line->dateFrom = $day->day;
$line->dateTo = $day->day;
$line->tags = $day->tags;
$this->lineAddTime($line, $timeFrom, $timeTo);
}
if ($day->day->format('Y-m-d') === $now->format('Y-m-d')) {
$line->setActive();
}
$lastTags = $day->tags;
$lastTimeFrom = $timeFrom;
$lastTimeTo = $timeTo;
$lastDay = $day;
}
$lastTimeTo !== NULL && $table->addLine($line);
$this->generatedTable = $table;
}
示例5: isOk
public function isOk()
{
$now = new DateTime();
if ($this->active && intval($this->getExpiration()->format("U")) > intval($now->format("U"))) {
return TRUE;
}
return FALSE;
}
示例6: update
public function update(Items\Base $item, $data)
{
if (preg_match('~^\\d{1,2}[/.]{1}[ ]{0,1}\\d{1,2}[/.]{1}[ ]{0,1}\\d{4}$~', $data, $arr)) {
$dateArr = preg_split('/[.\\/]{1}[ ]{0,1}/s', $arr[0]);
$date = new Nette\Utils\DateTime($dateArr[2] . '-' . $dateArr[1] . '-' . $dateArr[0]);
$data = $date->format('Y-m-d');
}
return $data;
}
示例7: toRequestArray
/**
* @return array of string
* @throws NoQueryException
*/
public function toRequestArray()
{
$ret = array();
$ret[self::$ID_DT] = $this->dt->format(Ares::REQUEST_DATE_FORMAT);
$ret[self::$ID_OUTPUT_FORMAT] = $this->outputFormat;
$ret[self::$ID_REQUEST_TYPE] = $this->requestType;
$ret[self::$ID_REQUESTS_COUNT] = $this->queryCount;
$ret[self::$ID_EMAIL] = $this->email;
$ret[self::$ID_REQUEST] = array();
if (!count($this->queries)) {
throw new NoQueryException();
}
foreach ($this->queries as $query) {
/* @var $query \Sasule\Ares\Query */
$ret[self::$ID_REQUEST][] = $query->toRequestArray();
}
return $ret;
}
示例8: getControlSettings
/**
* Get settings for control
*
* @return array
*/
protected function getControlSettings()
{
$settings = ['format' => $this->getDateTimeFormat(), 'daysOfWeekDisabled' => $this->daysOfWeekDisabled, 'autoclose' => $this->autoClose, 'startView' => $this->startView, 'minViewMode' => $this->minViewMode, 'todayHighlight' => $this->todayHighlight, 'inline' => $this->inline, 'multidate' => $this->multidate, 'multidateSeparator' => $this->multidateSeparator];
if (!empty($this->datesDisabled)) {
$dates = [];
foreach ($this->datesDisabled as $dateTime) {
$dates[] = $dateTime->format($this->getDateTimeFormat(TRUE));
}
$settings['datesDisabled'] = $dates;
}
if ($this->startDateTime != NULL) {
$settings['startDate'] = $this->startDateTime->format($this->getDateTimeFormat(TRUE));
}
if ($this->endDateTime != NULL) {
$settings['endDate'] = $this->endDateTime->format($this->getDateTimeFormat(TRUE));
}
return $settings;
}
示例9: toRequestArray
/**
* @return array of string
* @throws QueryMissingKeyPartException
*/
public function toRequestArray()
{
$ret = array();
if ($this->keyPart instanceof KeyPart) {
$ret[self::$ID_HELPER_ID] = $this->helperId;
if ($this->checkUsable($this->searchType)) {
$ret[self::$ID_SEARCH_TYPE] = $this->searchType;
}
$ret[self::$ID_KEY_PART] = $this->keyPart->toRequestArray();
if ($this->checkUsable($this->city)) {
$ret[self::$ID_CITY] = $this->city;
}
if ($this->dtValid instanceof DateTime) {
$ret[self::$ID_DT_VALID] = $this->dtValid->format(Ares::REQUEST_DATE_FORMAT);
}
if ($this->checkUsable($this->registerType)) {
$ret[self::$ID_REGISTER_TYPE] = $this->registerType;
}
$ret[self::$ID_MAX_COUNT] = $this->maxCount;
} else {
throw new QueryMissingKeyPartException();
}
return $ret;
}
示例10: getDay
/**
*
* @param DateTime|NULL $day
* @return WeekDay
*/
public function getDay(DateTime $day)
{
if (isset($this->specificDays[$day->format('Y-m-d')])) {
return $this->specificDays[$day->format('Y-m-d')];
} elseif (isset($this->openingHours[(string) $day->format('w')])) {
return $this->openingHours[(string) $day->format('w')];
}
return NULL;
}
示例11: ByPoint
/**
* Sestavi poradi bodu nezavisle na discipline v ramci oddilu.
* @param number $course Delka bazenu.
* @return object $data Poradi bodu.
*/
public function ByPoint($course)
{
$data = $this->database->query('
select -- 4. select
@rownum := @rownum + 1 AS rank,
sel_2.body,
sel_2.prijmeni,
sel_2.jmeno,
sel_2.rocnik,
sel_2.styl,
sel_2.cas,
sel_2.datum,
sel_2.zavod
from
(
select -- 2. select
sel_1.body as body,
plavci.surname as prijmeni,
plavci.firstname as jmeno,
plavci.year as rocnik,
styly.id as styl,
cas.time as cas,
zavody.date as datum,
zavody.name as zavod
from
sm_event zavody,
sm_stroke styly,
sm_swimmer plavci,
sm_time cas,
(
select -- 1. select
a.id_swimmer as plavec,
max(a.point) as body
from
sm_time a,
sm_event b,
sm_swimmer c
where
a.id_event = b.id and
a.id_swimmer = c.id and
b.lcm = ?
group by
a.id_swimmer
) sel_1
where
cas.id_swimmer = sel_1.plavec and
cas.point = sel_1.body and
cas.id_event = zavody.id and
cas.id_stroke = styly.id and
cas.id_swimmer = plavci.id and
zavody.lcm = ?
group by
sel_1.body
order by
sel_1.body desc
) sel_2,
(SELECT @rownum := 0) sel_3 -- 3. select', $course, $course)->fetchAll();
foreach ($data as $row) {
$formated_date = new DateTime($row->datum);
$row->datum = $formated_date->format('d. m. Y');
}
return $data;
}
示例12: renderCreate
public function renderCreate()
{
$dateNow = new DateTime();
$d = array('platneOd' => $dateNow->format(self::$dateFormat));
$this['nastenkaForm']->setDefaults($d);
}
示例13: footer
public static function footer()
{
$now = new DateTime();
return "\n" . "\n" . "-- {$now->format('Y-m-d H:i:s')}\n";
}
示例14: timeAgo
public function timeAgo(DateTime $d)
{
return Html::el('time')->setText($d->format('j.n.Y H:i'))->addAttributes(['datetime' => $d->format('c')]);
}
示例15: setValidated
public function setValidated($id)
{
$now = new \Nette\Utils\DateTime();
$this->localLoginModel->update($id, array("validated" => $now->format('Y-m-d H:i:s')));
}