Re: QuickForm date element
| From: | Bertrand Mansion | Date: | Wed, 31 Dec 2003 16:44:32 +0000 |
| Subject: | Re: QuickForm date element | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-9890@lists.php.net to get a copy of this message | ||
<bluesaphyer@yahoo.com> wrote :
> The code I'm using to insert the date element is:
>
> $this->addElement('date' , 'date' , 'Date: ' ,
> array('format' => 'Y-m-d' , 'minYear' => 1850 ,
> 'maxYear' => date('Y')));
>
> The drop down menu looks fine. Each selection for the
> month and day has the leading zero, but the value that
> is actually submitted does not have the zero.
>
> I can always check the length of the string after the
> form is submitted and add the zero if needed, but I
> was hoping there was a cleaner way.
>
> I'm using this along with the PEAR date package
> because my dates go back to far to use PHPs date
> functions, but the package will not recognize the date
> with only one digit for the month or day.
Then that's a Date package limitation. Looks weird though, a date class
that's not able to understand "3" and needs "03" instead...
Anyway, you can always use sprintf() to add the leading zeroes.
Bertrand Mansion
Mamasam