我在我的包中为 cronjob 创建了一个控制台命令页面。这是代码
类 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()); } } }
}
在这里我正在检索 mongo db date "$wish->getReservedDate()" 但我得到这样的输出
2013-07-03 13:46:42
3
Europe/Berlin
我如何仅获得前任的日期:2013-07-03 13:46:42