Search code examples
phpzend-frameworkdatetimedatezend-db

Inserting current date to MySql using Zend Date


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...


Solution

  • 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(); ?>