phpzend-frameworkdatetimezend-date

Zend Date giving me zeroes, why?


More problems with dates.

Basically I'm trying to populate a table with some datetime values from Zend. The datatype of the column that I'm trying to populate is 'datetime'. However, no matter which constant I try the column is always populated with zeroes. I've tried Zend_Date::ISO_8601, Zend_Date::DATETIME, Zend_Date::now() to no avail. Pleas help.

Here's the code:

           if(!$exists){
                $date_time = Zend_Date::DATETIME;
                /*
                 * Create the new site record
                 */
                $site_row = $site_table->createRow();
                //if(isset($n_r['id']))    $row->id  = $n_r['id'];
                $site_row->name         = $n_r['name'];
                $site_row->active       = 1;

                $site_id = $site_table->total() + 1;
                $address_id = $address_table->total() + 1;

                $site_row->id       = $site_id;
                $site_row->address_id       = $address_id;

                /*
                 * Create the address record to go with it
                 */
                $address_row = $address_table->createRow();
                $address_row->postcode = $n_r['postcode'];
                $address_row->address_line1 = $n_r['name'];
                $address_row->start_date = $date_time;

                $address_row->id = $address_id;
                $address_row->save();
                $array[] = $site_row->toArray();
                $site_row->save();

                /*
                 * Create the new site2address record to go with it
                 */
                $site2address_row = $site2address_table->createRow();
                $site2address_row->site_id = $site_id;
                $site2address_row->address_id = $address_id;
                $site2address_row->start_date = $date_time;
            }else{
                $array[] = $exists;
            }

Solution

  • mySQL expects input for DATETIME columns to be

    YYYY-MM-DD HH:MM:SS
    

    independent from the locale you are using. I can't see a Zend constant for that, you may need to format it yourself.