Answer the question
In order to leave comments, you need to log in
Date format on Select in ActiveRecord?
In the model, I make a request to the database, I get all the data that I need and the date in the format 2016-10-02 09:45:25+03 .
$query = (new \yii\db\Query())->
select('cd.date day,
c.host_id, cd.customer_id')
->from('customer_download cd')
->leftJoin('customer c', '"c"."id" = "cd"."customer_id"')
to_char(cd.date, 'YYYY-MM-dd HH24:MI') as day
Answer the question
In order to leave comments, you need to log in
$query = new \yii\db\Query();
$query ->select([
'day' => "to_char(cd.date, 'YYYY-MM-dd HH24:MI')",
'c.host_id',
'cd.customer_id'
])
->from('customer_download cd')
->leftJoin('customer c', '"c"."id" = "cd"."customer_id"')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question