在sql查询中将军事时间转换为标准时间

时间:2015-03-05 08:09:30

标签: php mysql phpactiverecord

我的php活动记录包含如下代码:

$app->get('/dailyReservationReport/request', function ($id=null) {
$status_code = 200;
$resp = array('status'=>'success','message'=>'Query Success','data'=>null);

//$resp['data'] = $id ?  Bus::find($id) : Bus::find_all_by_active('1'); 
$resp['data'] = Ticket::find_by_sql('SELECT routes.line as RouteLine , 
                                            tickets.trip_code as TicketTripCode,
                                            seating_types.code as SeatingTypesCode,
                                            trip_codes.time as TripCodeTime,
                                            tickets.departure_date as DepartureDate
                                     FROM tickets
                                     INNER JOIN routes
                                     ON tickets.route_code = routes.code
                                     INNER JOIN trip_codes
                                     ON tickets.trip_code = trip_codes.bus_class
                                     INNER JOIN seating_types
                                     ON trip_codes.bus_class = seating_types.id
                                     WHERE tickets.departure_date 
                                             BETWEEN "2015-02-04" AND "2015-03-04"');

if(is_object($resp['data'])){
        $resp['data'] = $resp['data']->to_array();
}else{
    $resp['data'] = objToArr($resp['data']);
}

JSONResponse($status_code,$resp);

});

我的问题是,当我得到tickets.departure_date as DepartureDate的结果时,它显示出军事时间。我希望在上午和下午的标准时间内转换它。我尝试添加像CONVERT(varchar(15),CAST(tickets.departure_date AS TIME),100)这样的一些转换,但它不起作用。有帮助吗?提前致谢!

0 个答案:

没有答案