DateTimePicker

Get started #

DateTimePicker helps you to pick a single date and time.

<?php
DateTimePicker::create(array(
    "name"=>"dueDate",
))
?>

Set locale #

<?php
DateTimePicker::create(array(
    "name"=>"dueDate",
    "locale"=>"it", //Italy
))
?>

Set format #

Please refer to format settings of DateRangePicker.

<?php
DateTimePicker::create(array(
    "name"=>"dueDate",
    "format"=>"MM/DD/YYYY", //Italy
))
?>

Set icon #

By default, DateTimePicker use the calendar icon on the right.To disable icon, you do:

<?php
DateTimePicker::create(array(
    "name"=>"dueDate",
    "icon"=>false
))
?>

If you want to change to another icon, you do:

<?php
DateTimePicker::create(array(
    "name"=>"dueDate",
    "icon"=>"glyphicon glyphicon-time"
))
?>

Set disabled dates #

Sometime you will need to prevent selection on some special date

<?php
DateTimePicker::create(array(
    "name"=>"dueDate",
    "disabledDates'=>array(
        "2017-12-12"
    )
))
?>

Set min date #

The DateTimePicker will disable selection on those days before the min set date.

<?php
DateTimePicker::create(array(
    "name"=>"dueDate",
    "minDate"=>"2017-06-28"
))
?>

Set max date #

The DateTimePicker will not allow user to pick those dates after set max date.

<?php
DateTimePicker::create(array(
    "name"=>"dueDate",
    "maxDate"=>"2017-06-28"
))
?>

Many times, you need to get selection [from,to] date range. the fromDate will allow only dates that before the date set nu to date.

<?php
DateTimePicker::create(array(
    "name"=>"fromDate",
    "maxDate"=>"@toDate"
))
?>
DateTimePicker::create(array(
    "name"=>"toDate",
    "minDate"=>"@fromDate"
))
?>

Client events #

DateTimePicker supports following events:

namedescription
showTriggered when the picker is shown
hideTriggered when the picker is hidden
showCalendarTriggered when the calendar(s) are shown
hideCalendarTriggered when the calendar(s) are hidden
applyTriggered when the apply button is clicked, or when a predefined range is clicked
cancelTriggered when the cancel button is clicked
<?php
DateTimePicker::create(array(
    ...
    "clientEvents"=>array(
        "apply"=>"function(e,picker){
            console.log(picker);
        }",
    )
));
?>

Options #

DateTimePicker still have many options to set, you may view the full list in here. If we need to add some more customization, we can add those to options.

<?php
DateTimePicker::create(array(
    "name"=>"dueDate",
    "options"=>array(
        "enabledDates'=>array('2017-4-22','2017-4-23','2017-4-25')
    )
))
?>