When I pull birthday date from the Facebook SKD I get DateTime Object, and I have been struggling convert it to string.
print_r($birthday);
DateTime Object ( [date] => 1978-03-09 00:00:00.000000 [timezone_type] => 3 [timezone] => Europe/Berlin )
But when i try to create another DateTime Object and convert it over to string
$date = new DateTime($birthday->date);
$result = $date->format('Y-m-d H:i:s');
I get
Undefined prperty: DateTime::$date
And when I
$date = new DateTime($birthday['date']);
$result = $date->format('Y-m-d H:i:s');
Cannot use object of type DateTime as array
Why try and create a new DateTime object use the one you have and just format the output
echo $birthday->format('Y-m-d H:i:s');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With