Closed gashik1979 closed 7 months ago
Hello!
I have some problem with date formation. For some reason, after creating the model, the time becomes UTC.
Model:
public function rules() { return [ .. [['time_range'], 'match', 'pattern' => '/^.+\s\-\s.+$/'], [['time_range'], 'default', 'value' => date('Y-m-d', strtotime('-1 month')) . ' - ' . date('Y-m-d')], ]; }
public function behaviors() { return [ [ 'class' => DateRangeBehavior::className(), 'attribute' => 'time_range', 'dateStartAttribute' => 'start_date', 'dateEndAttribute' => 'end_date', ] ]; }
Controller:
date_default_timezone_set('Europe/Moscow'); echo date('Y-m-d', strtotime('-1 month')) . ' - ' . date('Y-m-d')."<br>"; $searchModel = new StatisticSearch(); $dataProvider = $searchModel->search($this->request->queryParams); echo $searchModel->time_range; exit;
Output result: 2024-01-28 - 2024-02-28 2024-01-27 - 2024-02-27
The first output is correct, the time is Moscow time, but the second output is UTC for some reason.
я туплю, у меня фильтр был в ссылке
Hello!
I have some problem with date formation. For some reason, after creating the model, the time becomes UTC.
Model:
Controller:
Output result: 2024-01-28 - 2024-02-28 2024-01-27 - 2024-02-27
The first output is correct, the time is Moscow time, but the second output is UTC for some reason.
Operating System
Libraries