0
DateTime Object ( [date] => 2020-05-10 00:00:00.000000 [timezone_type] => 3 [timezone] => UTC ) 

above show when I do print_r below is the code

$bb=$row['dueDate'];

print_r($bb);
echo $bb->date;

now problem when i remove print_r command then $bb->date not show where as when print_r($bb) then it show echo data of $bb->date how to fixed this

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
Muhammad Farhan
  • 55
  • 1
  • 1
  • 5

2 Answers2

1

In general terms you don't echo objects.

For the DateTime class you possibly want to call the format() method. E.g.:

echo $bb->format('r');
Álvaro González
  • 142,137
  • 41
  • 261
  • 360
0

Follow @Álvaro González Answer.

You cannot echo directly from the date-time object. Try to use-

<?php
$bb = $row['dueDate']; //date-time object

echo date_format($bb, 'h:i:sa d M Y');  //use date_format($date_time_object, $date_format)
Sandip
  • 16
  • 4