class Zend_Date not found

1.1k Views Asked by At

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?

2

There are 2 best solutions below

0
Dolly Aswin On BEST ANSWER

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

2
Valvadis On

Under this link you have all zf3 components:

https://docs.zendframework.com/

It looks like there is no longer Zend_Date in zend framework components.

P.s.

I recommend using Carbon (http://carbon.nesbot.com) or built-in php date functions. I prefer object-oriented style:

http://php.net/manual/en/class.datetime.php