Answer the question
In order to leave comments, you need to log in
Where to store functions used in view in Yii?
Good evening!
There is a function that processes dates from the database to display the form:
"September 10-15" or October 30 - November 2"
public function getSeminarDate($date_begin, $date_end) {
if(Yii::$app->formatter->asDate('$date_begin', 'M') == Yii::$app->formatter->asDate('$date_end', 'M')) {
return Yii::$app->formatter->asDate('$date_begin', 'dd').'-'.Yii::$app->formatter->asDate('$date_end', 'dd');
}
else {
return Yii::$app->formatter->asDate('$date_begin', 'dd').' '.
Yii::$app->formatter->asDate('$date_begin', 'MMMM').'-'.
Yii::$app->formatter->asDate('$date_end', 'dd').' '.
Yii::$app->formatter->asDate('$date_end', 'MMMM');
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question