Cake\View\Helper\FormHelper::date PHP Method

date() public method

### Options: See dateTime() for date options.
See also: Cake\View\Helper\FormHelper::dateTime() for templating options.
public date ( string $fieldName, array $options = [] ) : string
$fieldName string Prefix name for the SELECT element
$options array Array of Options
return string Generated set of select boxes for time formats chosen.
    public function date($fieldName, array $options = [])
    {
        $options += ['empty' => true, 'value' => null, 'monthNames' => true, 'minYear' => null, 'maxYear' => null, 'orderYear' => 'desc'];
        $options['hour'] = $options['minute'] = false;
        $options['meridian'] = $options['second'] = false;
        $options = $this->_initInputField($fieldName, $options);
        $options = $this->_datetimeOptions($options);
        return $this->widget('datetime', $options);
    }

Usage Example

 /**
  * Generate date inputs.
  *
  * ### Options:
  *
  * See dateTime() for date options.
  *
  * @param string $fieldName Prefix name for the SELECT element
  * @param array $options Array of Options
  * @return string Generated set of select boxes for time formats chosen.
  * @see Cake\View\Helper\FormHelper::dateTime() for templating options.
  */
 public function date($fieldName, array $options = [])
 {
     $fields = ['year' => true, 'month' => true, 'day' => true];
     $this->templates(['dateWidget' => $this->_getDatetimeTemplate($fields, $options)]);
     return parent::date($fieldName, $options);
 }