Can't access property in PHP date object -
this question has answer here:
i'm creating datetime object with:
$datetime = date_create_from_format('y-m-d\th:i:sp', $string);
which gives object properties date
, timezone_type
, , timezone
. can't access of these properties:
return $datetime->date;
this returns null
. doing wrong?
edit:
var_dump($datetime) gives:
object(datetime)#807 (3) { ["date"]=> string(19) "2015-04-14 13:28:06" ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+00:00" }
there bug issue regarding in php. cant access directly. use format
method. try -
$datetime->format('y-m-d h:i:s')
Comments
Post a Comment