如何使用php $ row检索sql datetime对象? [英] how to retrieve a sql datetime object with a php $row?
本文介绍了如何使用php $ row检索sql datetime对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如:
$sql = "SELECT * FROM db";
$query = sqlsrv_query($conn, $sql);
while($row = sqlsrv_fetch_array($query)){
echo "$row[date_column]";
}
将崩溃
我发现大部分的答案都是假设你想用datetime命令你的查询,但是我只是希望在我拥有所有的行后把datetime对象变成一个字符串。
Most of the answers I've found are assuming you want to order your query by a datetime, but I just want to turn the datetime object into a string after I have all the rows.
我真的不明白如何使用php date()函数,
我试过:
I don't really understand how to use the php date() function, I've tried:
echo date("m/d/Y",$row[date_column]); //prints nothing
推荐答案
$string=$row["date_column"]->format('Y-m-d H:i:s')
这篇关于如何使用php $ row检索sql datetime对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文