Erroneous message is clear
date_modify($p, '-5 day');
expects $p be a DateTime object
but at this point it is a line because you are already formatted as a line with ->format() so change the order of your script:
$plantype = $allDbName->getPlanType(); $planEndOn = $allDbName->getNextPaymentDate(); $p = date_modify($planEndOn, '-5 day'); $date = $p->format('H:i:s \O\n Ym-d'); $output->writeln($date);
john smith
source share