In CakePHP, if i keep a table field type as date
, then it shows dropdown with month, day and year. However, the year range starts from 1990
only, how can I change it to start from 1900
?
You can use minYear
and maxYear
options of an input like this:
<?php
echo $this->Form->input('birth_dt', array(
'label' => 'Date of birth',
'dateFormat' => 'DMY',
'minYear' => date('Y') - 70,
'maxYear' => date('Y') - 18 ));
?>
Reference to cakePHP Cookbook
FYI: If current year is 2017 date('Y') - 70 will be 1947 [2017 - 70 = 1947].
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With