1

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?

pia-sophie
  • 505
  • 4
  • 21

2 Answers2

2

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

Dolly Aswin
  • 2,684
  • 1
  • 20
  • 23
0

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

Valvadis
  • 70
  • 10
  • yes I have seen that also, but is there no replacement? Of course I could user other products but I think within a framework you should mostly use the native classes, shouldn't you? – pia-sophie Jun 28 '17 at 09:38
  • Frameworks should help with creating apps, but today they brings us also easy way to integrate his files with external libraries (composer). For this reason, many frameworks have abandoned projects that somebody has developed better. When zf1 realeased, php didn't support DataTime classes. Today this components is completly unuseful. btw. For example Laravel using Carbon as default. – Valvadis Jun 28 '17 at 09:44