gpt4 book ai didi

php - Echo 不打印对象值

转载 作者:可可西里 更新时间:2023-11-01 07:58:52 24 4
gpt4 key购买 nike

<分区>

如果我取消注释 print_r($dateTime) 那么这个语句工作正常 echo $dateTime->date;

为什么会这样。请给我建议。

 $current_date=date('Y-m-d H:i:s');
$dateTime = DateTime::createFromFormat("Y-m-d H:i:s", $current_date, (new DateTimeZone('UTC')));

$dateTime->setTimezone(new DateTimeZone('PST'));
//print_r($dateTime); //If I print object then below echo stmt is working

echo $dateTime->date;

出现跟随错误

Notice: Undefined property: DateTime::$date in C:\xampp\htdocs\datetime.php 

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com