$date_format = ['type' => 'date','dateFormat'=>'YMD','minYear'=>date('Y')-10,'maxYear'=>date('Y')+10,'monthNames' => true];
echo $this->Form->control('birth_date',$date_format);
echo $this->Form->control('birth_date',$date_format);
If you want empty default date:
<?php
echo $this->Form->input(
'Profile.dob',
array(
'label' => 'Date picker',
'type' => 'date',
'dateFormat' => 'YMD',
'minYear' => date('Y') - 10,
'maxYear' => date('Y') + 10,
'empty' => array(
'day' => 'DAY',
'month' => 'MONTH',
'year' => 'YEAR'
)
)
);
?>
echo $this->Form->input(
'Profile.dob',
array(
'label' => 'Date picker',
'type' => 'date',
'dateFormat' => 'YMD',
'minYear' => date('Y') - 10,
'maxYear' => date('Y') + 10,
'empty' => array(
'day' => 'DAY',
'month' => 'MONTH',
'year' => 'YEAR'
)
)
);
?>
Please note, if you do like this, you can leave some of y/m/d empty:
<?php
$array = array(
'type' => 'date',
'label' => 'Date picker',
'dateFormat' => 'YMD',
'minYear' => date('Y') - 10,
'maxYear' => date('Y') - 10,
'empty' => array(
'day' => 'DAY',
'month' => 'MONTH',
'year' => 'YEAR'
)
);
$array = array_merge($array, ['value' => array(
'day' => '', //empty day
'month' => '8',
'year' => '2017'
)
]);
echo $this->Form->input(
'datepicker_test',
$array
);
?>
$array = array(
'type' => 'date',
'label' => 'Date picker',
'dateFormat' => 'YMD',
'minYear' => date('Y') - 10,
'maxYear' => date('Y') - 10,
'empty' => array(
'day' => 'DAY',
'month' => 'MONTH',
'year' => 'YEAR'
)
);
$array = array_merge($array, ['value' => array(
'day' => '', //empty day
'month' => '8',
'year' => '2017'
)
]);
echo $this->Form->input(
'datepicker_test',
$array
);
?>