I want to output a date object as string using ->format() but when i return the function php automatically convert it to string? how do i prevent that?
function setPassword($currOrder) {
            $checkInDate = $currOrder->checkInDate; // return date object 
            $checkIndate = $checkInDate->format('j/m/Y'); 
            print_r(gettype($checkIndate)); // output string
            return $checkInDate;
        }
print_r( gettype($thisGuest->setPassword($thisOrder)) );  // return object
				
                        
In this case the problem is caused becaus variables are case-sensitive, so
$checkIndateand$checkInDateare two different variables. Correct this and you should be fine.