Re: Re: Parsing the date from the HTML form helper
http://api.cakephp.org/classController.html#43aea5e84ef8550cf3ae8a97ca18ec1e On 12/15/06, Samuel DeVore <[EMAIL PROTECTED]> wrote: > you know about this right > > $this->cleanUpFields(); > > Sam D > > On 12/15/06, Rolo D. Monkey <[EMAIL PROTECTED]> wrote: > > > > I have this code in app/app_model.php. It parses the separate date > > fields created by $html->yearOptionTag(), $html->monthOptionTag, etc. > > and formats them to be put in a DATETIME column. > > > > It is a problem that comes up often enough that I think it might be > > useful to have this somewhere in the core. If not in Model then > > somewhere in the HTML form helper. Let me know what you think. > > > > function _getDate($model, $field) { > > > > $hour = isset($this->data[$model][$field . '_hour']) ? > > intval($this->data[$model][$field . '_hour']) : null; > > $min = isset($this->data[$model][$field . '_min']) ? > > intval($this->data[$model][$field . '_min']) : null; > > $sec = isset($this->data[$model][$field . '_sec']) ? > > intval($this->data[$model][$field . '_sec']) : null; > > $month = isset($this->data[$model][$field . '_month']) ? > > intval($this->data[$model][$field . '_month']) : null; > > $day = isset($this->data[$model][$field . '_day']) ? > > intval($this->data[$model][$field . '_day']) : null; > > $year = isset($this->data[$model][$field . '_year']) ? > > intval($this->data[$model][$field . '_year']) : null; > > > > return date('Y-m-d H:i:s', mktime($hour, $min, $sec, $month, $day, > > $year)); > > > > } // end function _getDate() > > > > > > > > > > > > > -- > == > S. DeVore > (the old fart) the advice is free, the lack of crankiness will cost you > -- == S. DeVore (the old fart) the advice is free, the lack of crankiness will cost you --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Re: Parsing the date from the HTML form helper
you know about this right $this->cleanUpFields(); Sam D On 12/15/06, Rolo D. Monkey <[EMAIL PROTECTED]> wrote: > > I have this code in app/app_model.php. It parses the separate date > fields created by $html->yearOptionTag(), $html->monthOptionTag, etc. > and formats them to be put in a DATETIME column. > > It is a problem that comes up often enough that I think it might be > useful to have this somewhere in the core. If not in Model then > somewhere in the HTML form helper. Let me know what you think. > > function _getDate($model, $field) { > > $hour = isset($this->data[$model][$field . '_hour']) ? > intval($this->data[$model][$field . '_hour']) : null; > $min = isset($this->data[$model][$field . '_min']) ? > intval($this->data[$model][$field . '_min']) : null; > $sec = isset($this->data[$model][$field . '_sec']) ? > intval($this->data[$model][$field . '_sec']) : null; > $month = isset($this->data[$model][$field . '_month']) ? > intval($this->data[$model][$field . '_month']) : null; > $day = isset($this->data[$model][$field . '_day']) ? > intval($this->data[$model][$field . '_day']) : null; > $year = isset($this->data[$model][$field . '_year']) ? > intval($this->data[$model][$field . '_year']) : null; > > return date('Y-m-d H:i:s', mktime($hour, $min, $sec, $month, $day, > $year)); > > } // end function _getDate() > > > > > -- == S. DeVore (the old fart) the advice is free, the lack of crankiness will cost you --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---
Parsing the date from the HTML form helper
I have this code in app/app_model.php. It parses the separate date fields created by $html->yearOptionTag(), $html->monthOptionTag, etc. and formats them to be put in a DATETIME column. It is a problem that comes up often enough that I think it might be useful to have this somewhere in the core. If not in Model then somewhere in the HTML form helper. Let me know what you think. function _getDate($model, $field) { $hour = isset($this->data[$model][$field . '_hour']) ? intval($this->data[$model][$field . '_hour']) : null; $min = isset($this->data[$model][$field . '_min']) ? intval($this->data[$model][$field . '_min']) : null; $sec = isset($this->data[$model][$field . '_sec']) ? intval($this->data[$model][$field . '_sec']) : null; $month = isset($this->data[$model][$field . '_month']) ? intval($this->data[$model][$field . '_month']) : null; $day = isset($this->data[$model][$field . '_day']) ? intval($this->data[$model][$field . '_day']) : null; $year = isset($this->data[$model][$field . '_year']) ? intval($this->data[$model][$field . '_year']) : null; return date('Y-m-d H:i:s', mktime($hour, $min, $sec, $month, $day, $year)); } // end function _getDate() --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~--~~~~--~~--~--~---