Php 如何从返回的数组对象访问日期成员变量
我正在尝试使用PHP从SQL 2008数据库服务器获取当前日期/时间。 当我对返回变量进行转储时,我会看到以下内容-Php 如何从返回的数组对象访问日期成员变量,php,sql-server,datetime,Php,Sql Server,Datetime,我正在尝试使用PHP从SQL 2008数据库服务器获取当前日期/时间。 当我对返回变量进行转储时,我会看到以下内容- array (size=1) <br /> 'current_date_time' => <br /> object(DateTime)[1] <br /> **public 'date' => string '2012-12-18 15:01:35' (length=19)** <br />
array (size=1) <br />
'current_date_time' => <br />
object(DateTime)[1] <br />
**public 'date' => string '2012-12-18 15:01:35' (length=19)** <br />
public 'timezone_type' => int 3 <br />
public 'timezone' => string 'UTC' (length=3) <br />
数组(大小=1)
“当前日期时间”=>
对象(日期时间)[1]
**公共“日期”=>string“2012-12-18 15:01:35”(长度=19)**
公共“时区类型”=>int 3
公共“时区”=>字符串“UTC”(长度=3)
问题:如何仅访问“date”变量?我尝试了以下方法,但没有成功:
return$row[“current\u date\u time”]->date
$row["current_date_time"]->format('Y-m-d H:i:s');
你应该做你需要的。看起来,
$row[“current\u date\u time”]
是一个对象。什么是“不起作用”的意思:您有错误吗?是的,我有错误,注意:未定义的属性:DateTime::$date在C:\wamp\www\cccac\cccac\u functions.php的第378行