PHP DateTime对象显示问题?

时间:2016-08-01 06:08:34

标签: php datetime

$currentDateTime = new DateTime();

echo "Date: " . $currentDateTime->date; // Not displaying
echo "<br>";
echo "Time: " . $currentDateTime->timezone; // Not Displaying
echo "<br>";

------------------------------------------------------------------

$currentDateTime = new DateTime();
$dataArr = (array) $currentDateTime;

echo "Date1: " . $dataArr["date"]; // Displaying
echo "<br>";
echo "Time1: " . $dataArr["timezone"]; // Displaying

为什么我无法直接从对象访问日期和时区? 我正在使用php 5.3.13

0 个答案:

没有答案