PHPackages                             metisfw/form-datetime - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Framework](/categories/framework)
4. /
5. metisfw/form-datetime

ActiveLibrary[Framework](/categories/framework)

metisfw/form-datetime
=====================

Forms control for adding date, date&amp;time and time fields for Nette Framework

v1.0.9(6y ago)0399BSD-3-ClausePHPPHP &gt;=5.4.0

Since Jan 12Pushed 4y agoCompare

[ Source](https://github.com/MetisFW/form-datetime)[ Packagist](https://packagist.org/packages/metisfw/form-datetime)[ Docs](https://github.com/iPublikuj/form-datetime)[ RSS](/packages/metisfw-form-datetime/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (8)Versions (13)Used By (0)

Form Date, Date&amp;Time and Time control
=========================================

[](#form-date-datetime-and-time-control)

[![Build Status](https://camo.githubusercontent.com/90acc05462a1594cd4e7b38cdf329248a36720d66f52444ccec40d65c59ba120/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6d6574697366772f666f726d2d6461746574696d652e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/metisfw/form-datetime)[![Latest Stable Version](https://camo.githubusercontent.com/bdd4022d4c1480d9a7c27838fb38d9b41d2d50ae41542940bb443f49b0c7361a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6574697366772f666f726d2d6461746574696d652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/metisfw/form-datetime)[![Composer Downloads](https://camo.githubusercontent.com/0f54141605ae428c5b044ac58bdd5205f865bf8f453388025ef47771b9a6c721/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6574697366772f666f726d2d6461746574696d652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/metisfw/form-datetime)

Based on abandoned library  by Adam Kadlec.

Forms control for adding date, date&amp;time and time fields for [Nette Framework](http://nette.org/) forms

This extension is based on two datetime libraries. For [Bootstrap](http://getbootstrap.com) template is used [js library](http://www.malot.fr/bootstrap-datetimepicker/) from [Sebastien Malot](https://github.com/smalot) and for [UIkit](http://getuikit.com/) template is used their [datepicker](http://getuikit.com/docs/addons_datepicker.html) and [timepicker](http://getuikit.com/docs/addons_timepicker.html) extensions.

Installation
------------

[](#installation)

The best way to install metisfw/form-datetime is using [Composer](http://getcomposer.org/):

```
{
	"require": {
		"metisfw/form-datetime": "dev-master"
	}
}
```

or

```
$ composer require metisfw/form-datetime:@dev
```

After that you have to register extension in config.neon.

```
extensions:
	formDateTime: MetisFW\FormDateTime\DI\FormDateTimeExtension
```

> In Nette 2.0, registration is done in `app/bootstrap.php`:

```
$configurator->onCompile[] = function ($configurator, $compiler) {
	$compiler->addExtension('formDateTime', new MetisFW\FormDateTime\DI\FormDateTimeExtension);
};
```

And you also need to include static files into your page:

```

```

note: You have to upload static files from **client-site** folder to your project.

Usage
-----

[](#usage)

```
$form->addDatePicker('date', 'Date picker:');
$form->addDateTimePicker('datetime', 'Date & time picker:');
$form->addTimePicker('time', 'Time picker:');
```

You can pass configuration for each type of form field:

### Settings for all types

[](#settings-for-all-types)

You can enable additional buttons which can control showed form field:

```
$form
	->addDateTimePicker('datetime', 'Date & time picker:')
	// Enable trigger button to open date/time picker
	->enableTriggerButton()
	// Enable cancel button to clear field
	->enableCancelButton();
```

### Settings for Date picker

[](#settings-for-date-picker)

Just setup how date picker window should display:

```
$form
	->addDatePicker('date', 'Date picker:')
	// Set week start day
	->setWeekStart(1) // 0 for sunday, 6 for saturday
	// Disable some days from week, this days can not be selected via picker
	->setDaysOfWeekDisabled([0, 6]);
```

### Settings for Time picker

[](#settings-for-time-picker)

Just setup how time picker window should display:

```
$form
	->addTimePicker('time', 'Time picker:')
	// Set week start day
	->setShowMeridian(TRUE) // Show time in meridian format (e.g. 04:15 PM)
```

### Settings for Date &amp; Time picker

[](#settings-for-date--time-picker)

This type of picker combines all settings from previous two types.

### Defining date and time formats

[](#defining-date-and-time-formats)

You can set for each field its format how value should be displayed in form.

```
$form
	->addDateTimePicker('datetime', 'Date & time picker:')
	// Set date format
	->setDateFormat('yyyy/dd/mm')
	// Set time format
	->setTimeFormat('hh:ii:ss');
```

This two methods require JS format, so for two digits day/mont and four digits year write dd/mm/yyyy etc.

### Validation

[](#validation)

Validation can be done as on usual text input and also this fields support special ranges values.

If you need to define some range for selecting value, you can use filed range rule:

```
$form
	->addDateTimePicker('datetime', 'Date & time picker:')
	// Set date format
	->addRule(\MetisFW\FormDateTime\Controls\DateTime::DATE_TIME_RANGE, 'Date must be between defined values', [(new Utils\DateTime(2015-01-01)), (new Utils\DateTime(2015-09-01))]);
```

This rule will also create min and max for picker window, so user will be not able to pick date out of defined range.

There are also nex two rules for minimal and maximal value:

```
$form
	->addDateTimePicker('datetime', 'Date & time picker:')
	// Set date format
	->addRule(\MetisFW\FormDateTime\Controls\DateTime::DATE_TIME_MIN, 'Date must be higher than selected', (new Utils\DateTime(2015-01-01)));
	->addRule(\MetisFW\FormDateTime\Controls\DateTime::DATE_TIME_MAX, 'Date must be lower than selected', (new Utils\DateTime(2015-09-01)));
```

### Custom templates and rendering

[](#custom-templates-and-rendering)

This control come with templating feature, that mean form element of this control is rendered in latte template. There are 3 predefined templates:

- bootstrap.latte if you are using [Twitter Bootstrap](http://getbootstrap.com/)
- uikit.latte if you are using [YooTheme UIKit](http://getuikit.com/)
- default.latte for custom styling (this template is loaded as default)

> But be aware, if you choose different template than UIkit or Bootstrap, JS will be deactivated!

You can also define you own template if you need to fit this control into your layout.

Template can be set in form definition:

```
$form
	->addDateTimePicker('datetime', 'Date & time picker:')
	->setTemplateFile('path/to/your/template.latte');
```

or in manual renderer of the form:

```
{?$form['datetime']->setTemplateFile('path/to/your/template.latte')}
{input datetime class => "some-custom-class"}
```

and if you want to switch default template to **bootstrap** or **uikit** just it write into template setter:

```
$form
	->addDateTimePicker('datetime', 'Date & time picker:')
	->setTemplateFile('bootstrap.latte');
```

or

```
{?$form['datetime']->setTemplateFile('bootstrap.latte')}
{input datetime class => "some-custom-class"}
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 61.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~177 days

Recently: every ~154 days

Total

10

Last Release

2549d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/34cfb80fd13dcc1cec1796b0c0f7fb2f5bc497b0142f658531b63a595081d336?d=identicon)[MartinMystikJonas](/maintainers/MartinMystikJonas)

---

Top Contributors

[![akadlec](https://avatars.githubusercontent.com/u/1866672?v=4)](https://github.com/akadlec "akadlec (35 commits)")[![MartinMystikJonas](https://avatars.githubusercontent.com/u/2094752?v=4)](https://github.com/MartinMystikJonas "MartinMystikJonas (10 commits)")[![jinovak](https://avatars.githubusercontent.com/u/11133173?v=4)](https://github.com/jinovak "jinovak (7 commits)")[![mervit](https://avatars.githubusercontent.com/u/6680486?v=4)](https://github.com/mervit "mervit (5 commits)")

---

Tags

frameworknettetimedateformtoolsipubtimepickerdatepicker

### Embed Badge

![Health badge](/badges/metisfw-form-datetime/health.svg)

```
[![Health](https://phpackages.com/badges/metisfw-form-datetime/health.svg)](https://phpackages.com/packages/metisfw-form-datetime)
```

###  Alternatives

[nasext/dependent-select-box

Dependent Select Box for Nette Framework.

21262.8k2](/packages/nasext-dependent-select-box)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
