Formatting Results Display

1

I need to show table data as date, I just do not know how to do the conversion.

It returns the result as it is in the database: 00000000 and need to return to 00/00/0000

I have the following code:

<?php while ($linha = mysqli_fetch_assoc($select)): ?>
    <table>
         <tr>
             <th>Data:</th>                         
             <td><?php echo $linha['DATA'] ?></td>
         </tr>
    </table>
<?php endwhile; ?>

My $select only has SELECT * FROM .

    
asked by anonymous 24.08.2018 / 16:16

2 answers

2

To format dates in PHP, you can use the date function:

date('d/m/Y', strtotime($linha['DATA']));
    
24.08.2018 / 16:20
2

The solution would be as follows:

<?php $novadata = date('d/m/Y', strtotime($linha['DATA'])); ?>
<td><?php echo $novadata ?></td>

strtotime to convert to time with / or -, save to a php variable and then print it.

    
24.08.2018 / 16:22