Why can’t I access DateTime->date in PHP’s DateTime class?

This is a known issue.

Date being available is actually a side-effect of support for var_dump() here – [email protected]

For some reason, you’re not supposed to be able to access the property but var_dump shows it anyways. If you really want to get the date in that format, use the DateTime::format() function.

echo $mydate->format('Y-m-d H:i:s');

Leave a Comment