When I try to create a record in a table using phpActiveRecord, I get the following error:
Invalid datetime format: 1292 Incorrect datetime value: '2013-06-20 11:59:08 PDT' for column 'created_at'
Executable code:
$new_cart = new QuoteRequest(); $new_cart->status = "cart"; $new_cart->save();
I traced this to the corresponding lines in phpActiveRecord. Connection.php file, lines 55-59:
static $datetime_format = 'Ymd H:i:s T';
And the line that uses this (Connection.php, lines 457-466):
public function datetime_to_string($datetime) { return $datetime->format(static::$datetime_format); }
And where the value is converted (table rows 394-412 tables):
private function &process_data($hash) { if (!$hash) return $hash; foreach ($hash as $name => &$value) { if ($value instanceof \DateTime) { if (isset($this->columns[$name]) && $this->columns[$name]->type == Column::DATE) $hash[$name] = $this->conn->date_to_string($value); else $hash[$name] = $this->conn->datetime_to_string($value); } else $hash[$name] = $value; } return $hash; }
I am using MySQL version 5.6.10, and the created_at field is a timestamp.
Question: Is something wrong with phpActiveRecord here, or is it a MySQL problem?
source share