PHP code example of venca-x / nette-date-time
1. Go to this page and download the library: Download venca-x/nette-date-time library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
venca-x / nette-date-time example snippets
//$configurator->createRobotLoader()
// ->addDirectory(__DIR__)
// ->addDirectory(__DIR__ . '/../libs')
// ->register();
VencaX\NetteDateTime\NetteDateTimePicker::register();
// Create Dependency Injection container from config.neon file
$form->addDate("name", "Label:", "type")
protected function concertForm()
{
$form = new UI\Form;
$form->addDate("datetime", "Date time:", "datetime")
->setValue(date("d.m.Y H:i"));
$form->addDate("date", "Date:", "date")
->setValue(date("d.m.Y"));
$form->addDate("month", "Month:", "month")
->setValue(date("d.m.Y"));
$form->addDate("month2", "Month2:", "month")
->setValue(date("m Y"));
$form->addDate("time", "time:", "time")
->setValue(date("H:i"));
$form->addDate("timesec", "timesec:", "timesec")
->setValue(date("H:i:s"));
$form->addSubmit('send', 'Show');
}
protected function concertForm()
{
$form->addDate("datetime", "Date time:", "datetime")
->setValue(new DateTime());
$form->addDate("date", "Date:", "date")
->setValue(new DateTime());
$form->addDate("month", "Month:", "month")
->setValue(new DateTime());
$form->addDate("time", "time:", "time")
->setValue(new DateTime());
$form->addDate("timesec", "timesec:", "timesec")
->setValue(new DateTime());
$form->addSubmit('send', 'Show');
}
$form->onSuccess[] = function ($form) {
dump($form->getValues());
$this->terminate();
/*
Nette\Utils\ArrayHash #6daf
datetime => Nette\Utils\DateTime #8732
date => "2017-08-25 21:48:00.000000" (26)
timezone_type => 3
timezone => "Europe/Prague" (13)
date => Nette\Utils\DateTime #c228
date => "2017-08-25 21:53:19.000000" (26)
timezone_type => 3
timezone => "Europe/Prague" (13)
month => Nette\Utils\DateTime #cd2a
date => "2017-08-25 21:53:19.000000" (26)
timezone_type => 3
timezone => "Europe/Prague" (13)
time => Nette\Utils\DateTime #7e7b
date => "2017-08-25 21:48:00.000000" (26)
timezone_type => 3
timezone => "Europe/Prague" (13)
timesec => Nette\Utils\DateTime #d546
date => "2017-08-25 21:48:51.000000" (26)
timezone_type => 3
timezone => "Europe/Prague" (13)
*/
};
$a = $form->getValues(true);
$a['datetime']->format('d.m.Y H:i');
$a['date']->format('d.m.Y');
$a['month']->format('m Y');
$a['time']->format('H:i');
$a['timesec']->format('H:i:s');