PHP How to get a parameter from an object?
you can just use
echo $dateObject->date; Otherwise, consider the DateTime#format method
echo $dateObject->format('Ymd H:i:s'); // => 2003-07-01 13:38:43 This is slightly better because it allows you to format the output as you would like.
I will look at the result of var_dump, you will see that you are dealing with an instance of the DateTime class:
object (DateTime) # 1 (3) {
Knowing this, you should go to the link to the PHP class and look at the documentation: http://php.net/manual/en/class.datetime.php
There you will find how to use this particular class. If you look at the list of methods, you will find the DateTime :: format method that you need. http://php.net/manual/en/datetime.format.php
Try
$datetime = new Datetime(); echo $datetime->format('Ymd H:i:s'); Take a look at http://php.net/manual/en/datetime.format.php