DrJohnZoidberg
Honorary Master
I've just started getting into Symfony and I'm busy writing a bundle to query my db tables and return json output.
What I'm trying to do is format my datetime type as a php formatted type and cannot figure out how I should go about this.
At the moment my datetime is being formatted like this:
What I want is something like this:
Here is the code snippet of my query:
and my twig file looks like this:
I would prefer not having to write a separate function to iterate through everything just to change the date format, I'm thinking there is a simpler way of doing this.
I've been looking into custom mapping types, but I'm a bit out of my depth here.
Anyone with some pointers here?
TIA
What I'm trying to do is format my datetime type as a php formatted type and cannot figure out how I should go about this.
At the moment my datetime is being formatted like this:
Code:
datestamp: "2014-08-11T23:50:06+0200"
What I want is something like this:
Code:
datestamp: "2014-08-11 23:50"
Here is the code snippet of my query:
Code:
$query = $repository->createQueryBuilder('p')
->select('p.datestamp','p.users')
->where('p.datestamp BETWEEN :start AND :end')
->setParameter('start', $graph_x_start)
->setParameter('end', $graph_x_end)
->orderBy('p.datestamp', 'DESC')
->getQuery();
$results = $query->getResult();
return $this->render('ORSDataFactoryBundle:Default:json.html.twig', array('json_output' => $results));
and my twig file looks like this:
Code:
{{ json_output | serialize }}
I would prefer not having to write a separate function to iterate through everything just to change the date format, I'm thinking there is a simpler way of doing this.
I've been looking into custom mapping types, but I'm a bit out of my depth here.
Anyone with some pointers here?
TIA