I need help to convert JSON
date into PHP
date format
I am trying to find a way to convert that date to m-d-Y
format in php
.
in my return I get
{
"result":"ok",
"ret":
{"count":7,
"setFirstResult":0,
"setMaxResults":5,
"data":[
{"id":218,
"name":"AAA",
"mes":"",
"updatetime":
{"date":"2019-09-18 12:25:42.000000",
"timezone_type":3,
"timezone":"Asia\/Taipei"
}
}
This is my controller
public function showMeg(Request $request, $page)
{
$entityManager = $this->getDoctrine()->getEntityManager();
$per = 5;
$start = ($page-1)*$per;
$query = $entityManager->createQueryBuilder()
->select("r")
->from("MegBundle:message", "r")
->setFirstResult($start)
->setMaxResults($per);
$data = $query->getQuery()->getArrayResult();
$paginator = new Paginator($query, $fetchJoinCollection = false);
$count = count($paginator);
$pages = ceil($count/$per);
return new JsonResponse(['result' => 'ok', 'ret' => ['data' => $data]]);
}
how can I convert normal time in that format using php
. e.g date('Y-m-d H:i:s')