Monday 15 February 2010

php - phpActiveRecord Incorrect DateTimeFormat -


I try the following error when trying to create a record in the table using phpActiveRecord:

Invalid date format: 1292 incorrect date time value: '2013-06-20 11:59:08' created for PDT 'column' '

The code that is going on Is: $ new_cart = new quote spacing (); $ New_cart- & gt; Status = "cart"; $ New_cart- & gt; Save ();

I have tracked it down to proper lines in phpActiveRecord File Connection.php, Lines 55-59:

  / ** * Date format of the database * @ Wise string * / static $ datetime_format = 'wi-m-dh: i: t';   

and this line (connection.fp, line 457-466) uses:

  / ** * Return date for the date format of the database Date time format. * * @ Ultimate DateTime $ Date Time Time Object * @ Return String * / Public Function datetime_to_string ($ datetime) {Return $ datetime- & gt; Format (static: $ datetime_format); }   

and where the value changes (table. Php lines 394-412):

  private function and process_data ($ hash) {if (! $ Hash) Return $ hash; Foreign currency ($ hash = $ name = & gt; & amp; $ value) {if ($ value instanceof \ DateTime) {if (isset ($ this-> column [$ name]) & amp; amp ; Amp; amp; amp; amp; $ - this- & gt; column [$ name] - & gt; type == column :: date) $ hash [$ name] = $ this- & gt; Conn- & gt; Date_to_ string ($ value); Else $ hash [$ name] = $ this- & gt; Conn- & gt; Datetime_to_string ($ value); } And $ hash [$ name] = $ value; } Return $ hash; }   

I am using MySQL version 5.6.10 and the created_at field is a timestamp.

Question: Is there something wrong with phpActiveRecord, or is it a MySQL problem?

  Fixed $ Datetime_format = 'Ymd H: IST';   

I think you should remove that 'T' (which gives you PDT , meaning the timezone abbreviation) Because it is not part of the timestamp format.

Should be:

  Fixed $ datetime_format = 'Ymd H: i: s';    

No comments:

Post a Comment