更新时间:2023-01-30 10:41:31
终于搞定了..比较两个日期以获得时间(天、小时和分钟)在控制器中:
Finally i got it.. compare the two dates to get a time (Days, Hours and minutes) in controller :
(教义查询)
TIMESTAMPDIFF(DAY,CURRENT_TIMESTAMP(), a.enddate) AS endday,
(TIMESTAMPDIFF(HOUR,CURRENT_TIMESTAMP(), a.enddate) - TIMESTAMPDIFF(DAY,CURRENT_TIMESTAMP(),a.enddate)*24) AS endhour,
(TIMESTAMPDIFF(MINUTE,CURRENT_TIMESTAMP(), a.enddate) - TIMESTAMPDIFF(HOUR,CURRENT_TIMESTAMP(), a.enddate)*60) AS endmin,
为 TIMESTAMPDIFF 创建了一个函数https://github.com/beberlei/DoctrineExtensions/blob/master/lib/DoctrineExtensions/Query/Mysql/TimestampDiff.php
Created a function for TIMESTAMPDIFF https://github.com/beberlei/DoctrineExtensions/blob/master/lib/DoctrineExtensions/Query/Mysql/TimestampDiff.php
并包含一个片段
app->config->config.yml教义:分贝:........
app->config->config.yml doctrine: dbal: ........
orm:
entity_managers:
default:
auto_mapping: true
dql:
datetime_functions:
timestampdiff: AcmeBUNDLEFOLDERTimestampDiff
谢谢大家..