Highcharts-从MS SQL到PHP的日期格式问题

Highcharts-从MS SQL到PHP的日期格式问题,php,datetime,highcharts,Php,Datetime,Highcharts,我一直在使用php从MS SQL数据库检索信息。我试图从表中检索日期和时间格式 这是我一直在使用的php: $tsql5a = "SELECT * FROM FactTime"; $stmt5a = sqlsrv_query( $conn, $tsql5a); $data5a = ""; while( $row = sqlsrv_fetch_array( $stmt5a, SQLSRV_FETCH_NUMERIC)){ $data5a .= "$row[1],"; } $data5a =

我一直在使用php从MS SQL数据库检索信息。我试图从表中检索日期和时间格式

这是我一直在使用的php:

$tsql5a = "SELECT * FROM FactTime"; 
$stmt5a = sqlsrv_query( $conn, $tsql5a);

$data5a = "";
while( $row = sqlsrv_fetch_array( $stmt5a, SQLSRV_FETCH_NUMERIC)){

$data5a .= "$row[1],";
}
$data5a = substr($data5a,0,strlen($data5a)-1);
我从表中检索的日期格式为:

2014-10-01 00:59:00.000

我得到以下错误:

可捕获的致命错误:类DateTime的对象无法转换为字符串

我研究过类似的问题,他们建议将其转换为字符串,但我完全不确定如何将其添加到现有的php中

有人能帮忙吗

谢谢
Rob

好的,我继续搜索,下面是答案

$data5a .= date_format($row[1]," Y-m-d H:i:s,");
我需要在从mssql db表中提取的数据行中添加一个日期格式,所以代码的完整部分就是这样的

$tsql5a = "SELECT * FROM FactTime"; 
$stmt5a = sqlsrv_query( $conn, $tsql5a);

$data5a = "";
while( $row = sqlsrv_fetch_array( $stmt5a, SQLSRV_FETCH_NUMERIC)){

$data5a .= date_format($row[1]," Y-m-d H:i:s,");    // I had to add a space before the Y and a comma after the s so the php would pass the right format to the chart
}
$data5a = substr($data5a,0,strlen($data5a)-1);      // This removes the last , from the array
我希望这能帮助其他有同样问题的人

谢谢 抢劫