Trying to echo a datetime field

So I am trying to learn PHP and convert a bunch of ASP Classic pages. I am trying to query a SQL Server database and return the results in a table. One of the fields is a datetime and is causing the page to fail. Here is the code:

<?php require_once("includes/conn_intranet.php")?>

$query = "SELECT * FROM issues WHERE status='open'";
$results = sqlsrv_query($conn, $query);?>

<table  class='table table-bordered table-condensed'>

<?php while ($row = sqlsrv_fetch_array($results)){?>
<td><?php echo $row['assigned']?></td>
<td><?php echo $row['customer']?></td>
<td><?php echo $row['jobno']?></td>
<td><?php echo $row['issue']?></td>
<td><?php echo $row['status']?></td>
<td><?php echo $row['assigner']?></td>
<td><?php echo $row['duedate']//line 29?></td> 
<td><?php echo $row['idate']?></td>
<?php } ?>

Open in new window

Here is the error:

Catchable fatal error: Object of class DateTime could not be converted to string in C:\inetpub\wwwroot\portal2\index2.php on line 29

How do I resolve this issue?

Thanks in advance.
Robert FrancisDirector of Continuous ImprovementAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Radek BaranowskiFull-stack Java DeveloperCommented:
you should probably use date_format() function

echo date_format($row['duedate'], 'Y-m-d H:i:s');

try if it works. good luck

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Robert FrancisDirector of Continuous ImprovementAuthor Commented:
Perfect. Wasn't sure what the syntax was. You're awesome.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.