I am working in a RESTFul API using Symfony2 and FOSRestBundle. The entities use Gedmo for Timestampable options:
use Gedmo\Timestampable\Traits\TimestampableEntity;
And I get the createdAt
as any other column:
$obj->getCreatedAt()
Then I pass that response to FOSRestBundle:
$respEmail = [
"id" => (string)$entEmail->getId(),
...
"category" => $entEmail->getEmailsCategory(),
"createdAt" => $entEmail->getCreatedAt()
];
$view->setData($respEmail)->setStatusCode(200);
And I get this:
{
"id": "5",
...
"category": "sent",
"createdAt": "2015-06-12T11:00:55-0430"
}
How do I fix the date? I want something like 2015-06-12 11:00:55
. Any help?
If it's a
DateTime()
object, and I assume it is, you should be able to do:More information on
DateTime::format()