You probably want: -
$mealplan->end_date = date_create();
$end_date = $mealplan->end_date;
Assign the value of the object property before assigning it to another PHP variable. Having done so you want (I assume) to carry this value to your template, so after this you do: -
$this->set(compact('end_date'));
If you don't need to access the `$end_date` variable in the controller, you need not create a separate copy of the `$mealplan->end_date` object variable. Therefore this can be simplified to: -
$mealplan->end_date = date_create();
$this->set('end_date', $mealplan->end_date);
Now in your template you can display this variable as passed by the controller via: -
<?= $end_date />
Because what the set{} is doing is loading up the variables passed to it for the template - which is how you can use $end_date
even though it need not exist in the controller as a variable. The compact is merely when the it does exist in the controller, and you want it to have the same variable name & value in the template - and you can pass an array so it really is nice & compact.