Inserting current date to MySql using Zend Date

user949852 picture user949852 · Sep 28, 2011 · Viewed 10.4k times · Source

I have a website based on Zend Framework. There is a form for users to fill in and the entered data is inserted in the database.

The users don't enter the date/time. I would like to populate the data value based on the current date/time . The date field is of type datetime.

i'm constantly getting the following error message:

Notice: Array to string conversion in D:\wamp\www\CNFSORG\library\Zend\Db\Statement\Pdo.php on line 228

I have tried doing the following:

<?php $date = new Zend_Date(); ?>

also tried doing:

<?php $date = new Zend_Db_Expr('NOW()'); ?>
<?php $date = new Zend_Db_Expr('CURDATE()'); ?>

I would be very grateful if someone could point me towards the right direction.

thanks in advance...

Answer

Pablo Morales picture Pablo Morales · Sep 29, 2011

The Correct answer is

<?php $date = new Zend_Db_Expr('NOW()'); ?>

You can try create a current timestamp from php with something like that

<?php  $date = new \DateTime(); ?>