I'd write a custom filter to do this and add it to your date elements in your
forms:
http://framework.zend.com/manual/en/zend.filter.writing_filters.html
http://framework.zend.com/manual/en/zend.form.elements.html#zend.form.elements.filters

Pretty sure you can instantiate a Zend_Date object with arbitrary data
formats - you can certainly output to arbitrary formats - but haven't tried
it specifically.  The documentation's pretty good at 
http://framework.zend.com/manual/en/zend.date.html

Cheers,
Mark




PHPScriptor wrote:
> 
> Ok, never understood how this worked, so a good explanation would be nice
> :-)
> 
> in my form, my date is: dd-mm-yyyy
> 
> $date[]       = self::createElement('text', 'mydate')
>       ->addValidator('Date', 'YYYY-MM-DD', array('DD-MM-YYYY'))
> 
> but for inputting it in my mysql the format needs to be yyyy-mm-dd.
> 
> What I do know to convert:
> 
> $formData = $this->_request->getPost();
> $date        = explode("-",formData );
> $formData['mydate'] = $date[2]."-".$date[1]."-".$date[0];
> 
> 
> 1. Is there a way to do this e.g. with Zend Date?
> 2. I do this in every controller. Is there a way to write a filter or
> something that could handle this? Or maybe extend my Zend_Form?
> 

-- 
View this message in context: 
http://www.nabble.com/Form-date-and-mysql-tp22988684p22989768.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to