User will select start date and end date from the datepicker in form and it will calculate the difference between two dates and the form will display the result which is number of days by using Yii PHP . I dont how to do the function for calculating the no of days and display the output.
class DateDiffModel
{
public $start;
public $parsedStart;
public $end;
public $parsedEnd;
public function rules()
{
return [
[['start', 'end'], 'required'],
[['start'], 'date', 'format'=>'yyyy-M-d', 'timestampAttribute' => 'parsedStart'],
[['end'], 'date', 'format'=>'yyyy-M-d', 'timestampAttribute' => 'parsedEnd'],
];
}
public function getDifference()
{
return $parsedEnd - $parsedStart;
}
}