如何将ZF2 Doctrine createQueryBuilder日期字段转换为时区

时间:2016-08-31 04:34:47

标签: php doctrine-orm zend-framework2 query-builder

这是我的疑问:

$casesData = $this->getEntityManager()->getRepository('Cases\Entity\Cases')
    ->createQueryBuilder('cases')
    ->select('cases.CaseId',
        'cases.CreatedDate',
        'cases.LeadId',
        'cases.InquiryID',
        'cases.FirstName',
        'cases.LastName',
        'cases.CityDoc1',
        'cases.StateDoc1',
        'cases.SSN',
        'cases.Status',
        'cases.CaseManagerId',
        'users.first_name'
);

cases.CreatedDate目前有"美国加拿大" timezone,现在我想根据时区下拉值进行转换,我无法按照上述查询找到任何转换时区的解决方案,请帮助我。

1 个答案:

答案 0 :(得分:0)

Actually with query builder you can't change the time zone, you have to use loop as doctrine return datetime object than you can modify the time as you wish

foreach($data as item){
   $date = $item['CreatedDate']->modify('....')
}