PHP code example of surda / datetime-period
1. Go to this page and download the library: Download surda/datetime-period 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/ */
surda / datetime-period example snippets
use Surda\DateTimePeriod\MonthPeriod\MonthPeriod;
use Surda\DateTimePeriod\MonthPeriod\MonthPeriodControl;
use Surda\DateTimePeriod\MonthPeriod\TMonthPeriod;
class ProductPresenter extends Nette\Application\UI\Presenter
{
use TMonthPeriod;
public function actionDefault(): void
{
/** @var MonthPeriodControl $mp */
$mp = $this->getComponent('mp');
/** @var MonthPeriod $monthPeriod */
$monthPeriod = $mp->getMonthPeriod();
}
}
class ProductPresenter extends Nette\Application\UI\Presenter
{
/**
* @return MonthPeriodControl
*/
protected function createComponentMp(): MonthPeriodControl
{
$control = $this->monthPeriodControlFactory->create();
$control->onChange[] = function (MonthPeriodControl $control, MonthPeriod $monthPeriod): void {
$this->redirect('this');
};
return $control;
}
}