protected function convertDateArrayToString($value) { if ($this->getOption('with_meridiem')) { if (!isset($value['meridiem']) || !in_array(strtolower($value['meridiem']), array('am', 'pm'))) { throw new sfValidatorError($this, 'invalid', array('value' => $value)); } if (strtolower($value['meridiem']) == 'pm') { $value['hour'] += 12; } } $ret = parent::convertDateArrayToString($value); $timestamp = strtotime($ret); sfContext::getInstance()->getLogger()->debug("Timestamp: " . $timestamp . ' for ' . date('Y-m-d H:i:s', $timestamp) . ' (' . date('Y-m-d h:i:s A', $timestamp) . ')'); return $ret; }
/** * Converts an array representing a date to a timestamp. * * The array can contains the following keys: year, month, day, hour, minute, second * * @param array $value An array of date elements * * @return int A timestamp */ protected function convertDateArrayToString($value) { /** * The (original) date validator was written to convert three or six single * input boxes to one date. * * We don't want that here, so we will take the value and convert it on our own, * if it seems to be a value submitted by our imput->date. */ if (array_key_exists(0, $value)) { //our value comes from the preg_match matches field return $this->convertPregDateToString($value); } return parent::convertDateArrayToString($value); }