Re[2]: [PEAR] QuickForm date element

From: Date: Wed, 31 Dec 2003 19:13:02 +0000
Subject: Re[2]: [PEAR] QuickForm date element
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-9892@lists.php.net to get a copy of this message
Hello Julie, Wednesday, December 31, 2003, 4:46:01 PM, you wrote: JK> 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'))); JK> The drop down menu looks fine. Each selection for the JK> month and day has the leading zero, but the value that JK> is actually submitted does not have the zero. Strange. I do it like this: $this->addElement('date','dataora_inizio', 'Data e ora di inizio', array('minYear' => 2003, 'language' => 'it', 'format' => 'd-m-Y H:i', 'optionIncrement' => array('i' => 5))); .... stuff .... $do_i = $page->exportValue('dataora_inizio'); and save it directly to the db, both "raw" as $do_i, and transformed back into a timestamp using a mktime on its parts: $ts_i = mktime($do_i['H'], $do_i['i'], 0, $do_i['m'], $do_i['d'], $do_i['Y']); the results include all the needed leading 0's. maybe somewhere between submit and check/save some operation /check is done that casts the date-string|parts to a number? that would explain the loss of the leading 0. JK> I can always check the length of the string after the JK> form is submitted and add the zero if needed, but I JK> was hoping there was a cleaner way. JK> I'm using this along with the PEAR date package JK> because my dates go back to far to use PHPs date JK> functions, but the package will not recognize the date JK> with only one digit for the month or day. JK> Thanks again. -- Best regards, Ing. Massimiliano Bariola Cell: ++39 329 3570098 REDLINK Italia S.a.s http://www.redlinkitalia.it mailto:m.bariola@redlinkitalia.it PGP Key: http://www.redlinkitalia.it/PGP/MB_PGPKEY.txt

« previous php.pear.general (#9892) next »