Using the DateTime
class, if I try to run the following code:
$mydate = new DateTime();
echo $mydate->date;
I\'ll get back
This is a known issue.
Date being available is actually a side-effect of support for
var_dump()
here – derick@php.net
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');