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
-~----------~----~----~----~------~----~------~--~---

Reply via email to