2013-09-02 3 views
0

내 번들에 cronjob에 대한 콘솔 명령 페이지를 만들었습니다. 여기 는하지만 내가symfony2의 저장된 날짜 가져 오기 doctrine mongodb

클래스 MyCommand이 명령 {

protected function configure() 
{ 
    $this 
     ->setName('cron:item_email') 
     ->setDescription('product notification for customer that reserved'); 
} 

protected function execute(InputInterface $input, OutputInterface $output) 
{ 

    $this->container = $this->getApplication()->getKernel()->getContainer(); 
    $em = $this->container->get('doctrine.odm.mongodb.document_manager'); 
    $wishlist = $em->getRepository('xxxxBundle:Wishlist')->findAll(); 
    foreach($wishlist as $wish){ 
     if($wish->getReservedDate()){ 
     // $output->writeln($wish->getId()); 
     $output->writeln($wish->getReservedDate()); 
    } 

    } 

} 

} 여기

나는 몽고 DB를 날짜를 검색하고 "를 $ wish-> getReservedDate()"확장 코드 이런 출력을내는 것

2013-07-03 13:46:42 
3 
Europe/Berlin 

난 단지 예에 대한 날짜 얻을 방법 : 2013년 7월 3일 13시 46분 42초

+1

나는'getReservedDate()'가'DateTime' 객체를 반환한다고 가정합니다. 왜'$ wish-> getResveredDate() -> format ('d/m/Y H : i : s')'을 사용하지 않을까요? – Touki

+0

도와 주셔서 감사합니다. –

답변

1

$ wish-> getReservedDate() -> 형식 ('D/m/YH : I : S')

또한 부업 메모로 ID에 저장된 날짜도 있습니다.

그냥

관련 문제