按日期时间排序数据 Symfony 2

Order data by datetime Symfony 2

我有一个包含数据的数组。我想使用类型为日期时间的属性“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)
   );
}

你试过了吗$congesshows = $em->getRepository('appUserBundle:Conges') ->createQueryBuilder(“c”)->orderBy(“CreatedAt”, 'DESC')->getQuery()->getResult() ;