Re: QuickForm 'date' defaults
| From: | Bertrand Mansion | Date: | Tue, 23 Sep 2003 08:15:55 +0000 |
| Subject: | Re: QuickForm 'date' defaults | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-7989@lists.php.net to get a copy of this message | ||
<keith@midnighthax.com> wrote :
> Code:
>
> =================================================
> $day = date("d");
> $month = date("M");
> $year = date("Y");
> $date_options = array(
> 'language' => 'en',
> 'format' => 'dMY',
> 'minYear' => $year-1,
> 'maxYear' => $year+1
> );
> $default_values['date'] = array('d'=>$day, 'M'=>$month,
> 'Y'=>$year);
>
> $form->addElement('date', 'date', 'Date:', $date_options);
> $form->setDefaults($default_values);
> =================================================
>
> When I display the form the date is '22 Jan 2003' rather than '22 Sep
> 2003'. Am I doing something stupid?
The value of your month select is always numeric. So you might prefer to use
$month = date("m") instead. 'M' is used to display the month names, but the
value actually sent is the month number.
HTH
Bertrand Mansion
Mamasam