Doctrine 仅按日期排序
Doctrine sort only by date
我有查询生成器:
$lastEvents = $em->getRepository('MyBundle:Entity')
->createQueryBuilder('e')
->select('e')
->where('e.to_trash = false')
->orderBy('e.created_at', 'DESC')
->setMaxResults(100);
和*.orm.yml:
created_at:
type: datetime
排序有效,但只能按日期(而不是时间)排序,如下所示:
2015 年 2 月 1 日 05:02:05
2015 年 2 月 1 日 03:02:02
01.02.2015 09:02:13
01.02.2015 09:02:01
29.01.2015 11:01:52
29.01.2015 11:01:22
必须是:
01.02.2015 09:02:13
01.02.2015 09:02:01
2015 年 2 月 1 日 05:02:05
2015 年 2 月 1 日 03:02:02
29.01.2015 11:01:52
29.01.2015 11:01:22
告诉我如何让它按时间排序?
我发现了我的愚蠢错误:
我像这样使用树枝:
date|date("d.m.Y h:m:s")
但必须(24时间格式):
date|date("d.m.Y H:i:s")
我有查询生成器:
$lastEvents = $em->getRepository('MyBundle:Entity')
->createQueryBuilder('e')
->select('e')
->where('e.to_trash = false')
->orderBy('e.created_at', 'DESC')
->setMaxResults(100);
和*.orm.yml:
created_at:
type: datetime
排序有效,但只能按日期(而不是时间)排序,如下所示:
2015 年 2 月 1 日 05:02:05
2015 年 2 月 1 日 03:02:02
01.02.2015 09:02:13
01.02.2015 09:02:01
29.01.2015 11:01:52
29.01.2015 11:01:22
必须是:
01.02.2015 09:02:13
01.02.2015 09:02:01
2015 年 2 月 1 日 05:02:05
2015 年 2 月 1 日 03:02:02
29.01.2015 11:01:52
29.01.2015 11:01:22
告诉我如何让它按时间排序?
我发现了我的愚蠢错误:
我像这样使用树枝:
date|date("d.m.Y h:m:s")
但必须(24时间格式):
date|date("d.m.Y H:i:s")