Skip to content
Advertisement

php Object of class DateInterval could not be converted to string

i’ve tried using date_diff and date_create to get a difference from two date that’s already converted to string.

here’s the code:

JavaScript

and i am getting this error:

JavaScript

Advertisement

Answer

You need to call DateInterval::format() to display that difference as a string.

JavaScript

See the manual for all of the available formatting options.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement