jeudi 1 octobre 2015

Time Format not working in Laravel Query builder select

I have a query in Laravel query builder like this-

    $ownQas = DB::table('qas')
                ->join('users', 'users.id', '=', 'qas.subscriber_id')
                ->select(
                            'qas.question as question',
                            'qas.created_at as question_datetime',
                            'users.name as question_name',
                            DB::raw('NOW() - UNIX_TIMESTAMP(qas.created_at) as question_ask_before'),
                            'qas.answer as answer'
                        )
                ->where('qas.webinar_id', '=' , $webinar['id'])
                ->where('qas.subscriber_id', '=' , Auth::user()->id)
                ->where('qas.public', '=' , 0)
                ->get();

It is working.

But if I try to find timestamps as formatted like this-

DB::raw('TIME_FORMAT((NOW() - UNIX_TIMESTAMP(qas.created_at)),"%H:%i") as question_ask_before')

I am getting error.

Any idea?

Thanks for helping.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1OaaGa6
via IFTTT

Aucun commentaire:

Enregistrer un commentaire