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
?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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].