How to convert a DateTime object to string?

0

I need to convert a DateTime to a string, I have the following error:
Catchable fatal error: Object of class DateTime could not be converted to string.

I print a column of an HTML table in this way:

<td align = "center"> <?php echo $linha["data_pagto"]; ?> </td>
    
asked by anonymous 20.12.2017 / 16:08

2 answers

0

With a brief search I found the following solution:

<td align = "center"> <?php echo date_format($linha["data_pagto"], 'd/m/y');?> </td>
    
20.12.2017 / 16:33
0

You can use date_format, here is an example:

<?php $date = date_create('2013-11-23 05:06:07'); echo date_format($date, 'Y-m-d'); ?> 

Demo: link

    
20.12.2017 / 16:14