Display date from Express object

Permalink 1 user found helpful
I'm running into a problem where i'm unable to display the date i entered in my Express Object attribute. Displaying strings and images work just fine.
'dateofbirth' => $employee->getEmployeeDateofbirth(),

I use the following to display the data:

'.$employee['dateofbirth'].'

I could use textfields (strings), but i'd really like to use the builtin date selector.

Could anyone explain me what i'm doing wrong?

 
MrKDilkington replied on at Permalink Best Answer Reply
MrKDilkington
Hi Snor,

The result of $employee->getEmployeeDateofbirth() is likely going to be a DateTime object. The DateTime object can't be displayed as is. You can use the format() method to format it as a string.
http://php.net/manual/en/datetime.format.php...
http://php.net/manual/en/function.date.php...

Example:
$dateofbirth = $employee->getEmployeeDateofbirth();
echo $dateofbirth->format('F j, Y');
Snor replied on at Permalink Reply
That worked wonders, thank you!