如何从DateTime
对象中获取日期?
输出为:
Array (
[0] => stdClass Object (
[instrument_token] => 16796674
[exchange_token] => 65612
[tradingsymbol] => DABUR18MAR445CE
[name] =>
[last_price] => 0.05
[expiry] => DateTime Object (
[date] => 2018-03-28 00:00:00.000000
[timezone_type] => 3
[timezone] => asia/kolkata
)
[strike] => 445
[tick_size] => 0.05
[lot_size] => 2500
[instrument_type] => CE
[segment] => NFO-OPT
[exchange] => NFO
)
)
答案 0 :(得分:0)
此处DateTime Object
是对象的字符串表示形式(请参阅__toString()
)。
您可以使用DateTime::format()
获取所需的字符串:
$date_str = $array[0]->expiry->format('Y-m-d H:i:s');