Format table date mysql and show in Smarty

0

I'm developing a page in PHP, using MVC structure and rendering the tamplete files with Smarty.

However, you have been struggling to get a date via MySQL (see the format: YEAR-MONTH-DAY HOUR: MINUTE: SECOND

I'd like it to appear in the following form: DAY / MONTH / YEAR - TIME: MINUTE

I have already managed to get the data in MySQL, as shown below:

    $feed = new feedAction();
    $feedPostsSelect = $feed->select();
    $view->assign("feedList",$feedPostsSelect);

    $view->assign("textFeed", "text");
    $view->assign("usuarioFeed", "idauthor");
    $view->assign("publishDateFeed", "publishDate");

And in the tpl file:

{$row.publishDate}

I've tried as in timestamp of the smarty shows, which would be:

{$smarty.now|date_format:"%d/%m/%Y - %H:%M"}

However, using row.publishDate | date_format does not work if you want to display some data on the screen.

How to proceed?

Thank you for your attention!

    
asked by anonymous 16.10.2016 / 05:30

1 answer

1

Problem solved successfully! In the query, where the data will be pulled from the database, it is necessary to get already formatted, that is, the query will be:

SELECT *, DATE_FORMAT(T1.publishDate, '%%d/%%m/%%Y - %%H:%%i') AS publishDateFormated FORM tabela;

Although no one has helped so far, I hope my own answer will help someone! :)

    
17.10.2016 / 01:34