change PHP date format [duplicate]

0

When I make an INSERT in the bdd using a form one of the columns automatically generates the date in which it was made, the case is that it is stored with this format

2017-03-29 17:12:16

What I am trying to solve is to change the format to dd / mm / yyyy when it is displayed on the screen

I'm using phpMyAdmin to manage the bdd, from there you can modify the format? or does it have to be by php? if the latter case is how it could be done?

thanks in advance

    
asked by gmarsi 29.03.2017 в 17:36
source

2 answers

2

You could do it from PHP and it would be something like this:

$fecha = 2017-03-29 17:12:16;

$nueva_fecha = date("d-m-Y",strtotime($fecha));
    
answered by 29.03.2017 / 17:38
source
1

Or you can change the format in the query when collecting data from the database.

SELECT DATE_FORMAT(MI_FECHA,'%d/%m/%Y') AS FECHA FROM MI_TABLA;

And you already directly show the field 'DATE'.

    
answered by 29.03.2017 в 18:31