views:

27

answers:

3

Hope that title isn't too cryptic. I have an array with a DATETIME object in it and I'm just trying to figure out how to echo this to a page.

 ["created"]=> object(DateTime)#3 (3) { ["date"]=> string(19) "2010-10-22 00:00:00" ["timezone_type"]=> int(3) ["timezone"]=> string(13) "Europe/London"

Can someone help me out?

tried date() but get:

Warning: date() expects parameter 2 to be long, object given in C:\

any help most appreciated,

Jonesy

+2  A: 

http://www.php.net/manual/en/datetime.format.php

echo date_format(myArray["created"], "the format you want for your date");

Formatting:

http://www.php.net/manual/en/function.date.php

Evan Mulawski
+2  A: 

Use DateTime::format(). The mask syntax is identical to date()'s.

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

If it's an actual php5 DateTime object then you can use the format method to echo it

$myDate = $myArray['created'];
echo $myDate->format('Y-m-d H:i:s');
Dave