zend-frameworkzend-framework3zend-date

class Zend_Date not found


I googled a lot until now, but I couldn't find anything that works.

I need to save a proper datetime value in my mySQL database, so I tried as used in ZF1 this one:

$date = new Zend_Date();
echo $date->toString('YYYY-MM-dd HH:mm:ss');

I got the error class Zend_Date not found

Blockquote

What is it in ZF3, is it deprecated? If yes how is the name of the new class and how to get with composer. If not, what is wrong, what do I need as use statement.

Of course this one works

$heute = date("Y-m-d H:i:s"); 

But the question is furtherhin why can't I use Zend_Date?


Solution

  • When PHP 5.3 released, it has DateTime built in class. That's why Zend_Date was not used anymore. So, since ZF2 Zend_Date was not exist anymore.

    So, just use DateTime built in class, and this doesn't need loaded in composer. http://php.net/manual/en/class.datetime.php