我有一个包含数据的数组。我想使用类型为日期时间的属性“CreatedAt”按日期(列表开头的新数据)显示我的数据。这是我的控制器:
{
$em = $this->getDoctrine()->getManager();
$user= $this->get('security.context')->getToken()->getUser();
$congesshows = $em->getRepository('appUserBundle:Conges')
->findBy(array(),array('CreatedAt'=>'DESC'))
;
$role = $user->getRoles() ;
if($role[0]== "ROLE_ADMIN") {
$congess = $em->getRepository('appUserBundle:Conges')
->findBy( array('etat' => 'En cours'))
;
}
else {
$congess = $em->getRepository('appUserBundle:Conges')
->findBy(array('etat' => 'En attente'))
;
}
return $this->render(
'appUserBundle:interne:please.html.twig',
array('conges' => $congess,'congesshows'=>$congesshows)
);
}