Using the DateTime
class, if I try to run the following code:
$mydate = new DateTime();
echo $mydate->date;
I\'ll get back
Besides calling DateTime::format()
you can access the property using reflection:
getProperty('date');
$date = $p->getValue($dt);
This is slight faster than using format()
because format()
formats a timestring that has already been formatted. Especially if you do it many times in a loop.
However this is not a regular behaviour of PHP. A bugreport has already been filed as @Nile mentioned in the comments above.