我正在做一个Laravel项目。我正在尝试从时间戳中获取时间。这是我用来实现这一点的代码:
$details=DB::table('CourseListNew as cl')
->select(
'cl.Title',
'p.Title as ParentTitle',
'cd.Trainer',
DB::raw('day(cd.StartingDate) as day'),
DB::raw('day(cd.EndingDate) as day_end'),
DB::raw('(cd.StartingDate) as month'),
DB::raw('year(cd.StartingDate) as year'),
DB::raw('time(cd.StartingDate) as start_time'),
DB::raw('time(cd.EndingDate) as end_time'),
'cd.StartingDate',
'cd.EndingDate',
'cd.Duration',
'cd.Type',
'cd.Fee',
'cd.Venue',
'count (s.Id) as TotalRegistartion'
)
->join('CourseListNew as p','p.Id', '=', 'cl.ParentId','left')
->join('CourseDetailsNew as cd','cd.CourseId', '=', 'cl.Id')
->join('Student as s','s.CourseId', '=', 'cl.Id', 'left outer')
->orderBy('cl.Id','DESC')
->get();
我想获得12小时的AM/PM格式的时间,但无法找到任何工作的解决方案。我没有使用雄辩。
发布于 2020-09-15 17:32:29
使用Mysql DATE_FORMAT
DB::raw('DATE_FORMAT(cd.EndingDate,'%Y-%m-%d %h:%i %p') as end_time')
https://stackoverflow.com/questions/63897148
复制相似问题