How to convert a Datetime object to string?

Asked

Viewed 223 times

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 in a column of an HTML table like this:

<td align = "center"> <?php echo $linha["data_pagto"]; ?> </td>

2 answers

0

  • I did exactly that there and gave "date_create() expects Parameter 1 to be string, Object Given" and "date_format() expects Parameter 1 to be Datetimeinterface, Boolean Given"

  • Isn’t it because of the single quotes? The same happens with double quotes?

  • found the following solution: <td align = "center"> <?php echo date_format($line["data_pagto"], ’d/m/y');? > </td>

0


with a brief search I found the following solution:

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

Browser other questions tagged

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