0
我试图使用KnpTimeBundle得到以前的日期时间。
作为文件建立说,我需要使用辅助类来接取DIFF()功能:
看看我Controller.php这样:使用KnpTimeBundle返回两个DateTime对象之间的差异
use Knp\Bundle\TimeBundle\Templating\Helper as Helper;
/**
* @Route("/test",name="test")
* @Method({"GET","POST"})
*/
public function testAction(Request $request){
$date = new \DateTime("now");
$h=new Helper();// here i got a 404 error
$ago=$h->diff($date);
return $this->render('test.html.twig', array());
}
但是通过这种方式didnt调用Helper类为我工作,任何人都可以给我正确的方法来实现这个诀窍。