class Certification extends ActiveRecord...
{
//...
/**
* Получаем обратную дату окончания действия категории
* @return string
*/
public function getReverseEndDate(): string
{
$date = date_create($this->date_from); //подготавливаем дату для рассчёта срока
$date = date_modify($date, '-'.$this->category->duration_months.'month'); //Вычитаем дату от текущей
return Yii::$app->formatter->asTimestamp($date);
}
public function getValidCategory()
{
return $this->hasOne(Category::className(), ['id' => 'category_id'])
->andWhere(['<=', 'date_from', 'reverseEndDate']);
}
$certifications = Certification::find()
->joinWith(['user', 'profile', 'validCategory'])
->andWhere([User::tableName().'.status' => User::STATUS_ACTIVE])
->andWhere('CONCAT_WS(" ", '.Profile::tableName().'.last_name, '.Profile::tableName().'.name, '.Profile::tableName().'.middle_name) LIKE :search')
->params([':search' => '%' . $search . '%'])
->orderBy([Profile::tableName().'.last_name' => 'SORT_ASC', Profile::tableName().'.name' => 'SORT_ASC'])
->limit(8)
#->isValid() //?? метод из модели CertificationQuery уже не нужен
->all();
'formatter' => [
'class' => 'yii\i18n\Formatter',
'timeZone' => 'Europe/Moscow',
'datetimeFormat'=> 'dd MMMM YYYY HH:mm:ss',
'dateFormat' => 'dd MMMM YYYY',
'timeFormat' => 'HH:mm:ss',
...
],
<?= \Yii::$app->formatter->asDatetime($portfolio['date']);?>
<?= \Yii::$app->formatter->asDatetime($portfolio['date'], 'dd MMMM в HH:mm');?>
phpinfo()
'formatter' => [
...
'locale' => 'uk-UA'
...
],
[HOST=www.site.ru]
mbstring.func_overload=2
ini_set('mbstring.func_overload' , 2);
public function ApiPos($fields)
{
$ch = curl_init($serverUrl. '?' .http_build_query($fields));
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Accept: application/json',
"Authorization: Bearer {$token}"
);
$result = curl_exec($ch);
$result = json_decode($result, true);
curl_close($ch);
return $result;
}
$store = new Store();
/** @property $collection ItemCollection */
$store->collection->add(Item $item);
$store->collection->remove($item);
...
$location = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
curl_setopt($ch, CURLOPT_POSTREDIR, 7);
curl_setopt($ch, CURLOPT_MAXREDIRS, $max_redirects);
echo implode(PHP_EOL, $randArray);
echo implode('<br>', $randArray);
foreach($randArray as $item) {
echo $item;
}
$id = 15;
echo str_pad($id, 10, "0", STR_PAD_LEFT); // выведет 0000000015
...
$row['id_ad_1c'] = str_pad($row['id'], 10, "0", STR_PAD_LEFT)
$result[] = $row
...
function generateNumber($length = 10)
{
$chars = ['0','1','2','3','4','5','6','7','8','9']; //можно дополнять и буквами
$number = '';
$count = count($chars);
for($i = 0; $i < $length; $i++) {
$number .= $chars[mt_rand(0,$count)];
}
return $number;
}
echo "ym:pv:URL=='{$entry->link}'"
echo mb_substr_count('Строка по которой ищем подстроки', 'о'); //выведет 7