How to format Mysql date and time for the Brazilian PHP format?

Asked

Viewed 2,795 times

0

My two doubts are as follows::

1) When I retrieve the date and time (datetime) of the bank comes in this format (for example):

2016-11-12 11:19:34

But I want to show it this way:

11:19:34 12/11/2016

How to do this?

2) How I get the date and time in PHP, to insert into the database with this format:

2016-11-12 11:19:34

  • It has certainly already been answered in one of these: https://answall.com/search?q=+%5Bphp%5D+format+data

  • 2

    In short, direct in Mysql is SELECT DATE_FORMAT(seu_campo_data,'%d/%m/%Y') AS data_formatada FROM sua_tabela. PHP version has a lot of response on the site, as indicated by @Maniero link.

  • Use the NOW() in his query in PHP that will solve the second problem. The now will already return the current moment, fully understandable for Mysql.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.