pdo date format

0

hi I want to show the date in this format in a query "d-m-Y" because when the storage in the bd is stored in this way "Y-m-d" type date append a piece of my query, thanks in advance

 'while ($linea = $consulta->fetch(PDO::FETCH_ASSOC)) {
echo "<tr>
<td align=center>$i</td>
<td align=center>{$linea['nombres']}\n{$linea['apellidos']}</td>
<td align=center>{$linea['email']}</td>
<td align=center>{$linea['mensaje']}</td>
<td align=center>{$linea['fecha']}</td>'
    
asked by yoclens 13.02.2017 в 06:50
source

1 answer

1

You can use the date function and the strtotime

  $date_bd = '2016-12-28';
  echo date('d-m-Y', strtotime($date_bd));

For your example it would be:

$fecha = date('d-m-Y', strtotime($linea['fecha']))
<td align=center>{$fecha}</td>
    
answered by 13.02.2017 / 07:09
source