title = 'Статистика'; $sourcesDays = array_keys($sourcesStats); krsort($sourcesDays); $types = []; foreach ($sourcesStats as $key => $value) { $types = array_merge($types, array_keys($value)); } $types = array_filter(array_unique($types)); $sourcesToday = $sourcesDays[count($sourcesDays) - 1]; $sourcesYesterday = $sourcesDays[count($sourcesDays) - 2]; $latestRequestTime = function($date) { $timestamp = (new DateTime($date))->getTimestamp(); switch (date('d', $timestamp)) { case date('d', time()): return '' . date('(H:i)', $timestamp) . ''; case date('d', strtotime('-1 day')): return '' . date('(вчера H:i)', $timestamp) . ''; } }; $viberTime = function($date) { $hours = date('H'); $time = null; if ($hours > 10 && $hours < 22) { $time = '-30 minutes'; } else { $time = '-1 hour'; } if (strtotime($time) > (new DateTime($date))->getTimestamp()) { return 'style="border-bottom: 2px red dashed;"'; } return null; }; ?> select(['phone', new \yii\db\Expression('MAX(tm) as tm')]) ->from('cache') ->where(['type_id' => $type]) ->andWhere(['and', ['<>', 'data', '[]'], ['<>', 'data', 'null']]) ->groupBy('phone') ->orderBy(['tm' => SORT_DESC]) ->one(); ?>
Дата -
> - % % - -