I'm new to Zend framework and have decided to try to build a simple app using ZF2.
I have a date that is being pulled from the database where my table gateway extends the AbstractTableGateway, this is pulling my data correctly but i'd like to format my date using Zend_Date and not manipulate the string representation myself in my model / view.
Does anybody have any ideas about how i do this?
Here is my custom datatime helper for reference:
https://github.com/AlloVince/eva-engine/blob/master/vendor/Eva/View/Helper/Datetime.php
register this helper as a invokable helper service in your module config file
Then call it in view by:
Another option would be the already present ViewHelper \Zend\I18n\View\Helper\DateFormat
This way you could ensure that your view-scripts are ready for internationalization (i18n) and that all your page viewers would be able to see the date in their respective formats.
This requires the php_intl extension to be enabled.
The long usage would look something like the following:
However, just like AlloVince's approach, i would suggest writing your own view-helper for that. This way you could write something like
$this->myDateFormat($db->getDate())