-1

I just want to do this simple task with Zend Framework:

<input type="hidden" name="modification_date" value="<?php echo new Zend_Db_Expr('NOW()');?>" />

As you can see I'm trying to instantiate Zend_Db_Expr to be able to insert a date in an input with NOW() in a View, however this is not working, because what I've got is this value="NOW" instead of something like this value="2012-10-04 12:14:56"

Seems quite simple. I had this working before but U had to uninstall and reinstall MySQL for another reason and now it doesn't work.

I've also tried new Zend_Db_Expr('SELECT NOW();') because in my MySQL if I execute NOW this way I got the date.

halfer
  • 19,824
  • 17
  • 99
  • 186
Metafaniel
  • 29,318
  • 8
  • 40
  • 67
  • If you want this done in Mysql you don't need any code in your application. Just set a column on your table to TIMESTAMP with a default value of Current http://dev.mysql.com/doc/refman/5.0/en/timestamp-initialization.html – RockyFord Oct 06 '12 at 06:58

1 Answers1

2

Zend_Db_Expr doesn't return value of your statement. It returns specific predefined string for query. Why you can not use Zend_Date?

<input type="hidden" name="modification_date" value="<?php echo Zend_Date::now();?>" />
Alex Pliutau
  • 21,392
  • 27
  • 113
  • 143