I have not tested this, but you problem probably stems from the fact that “Ymd” in not a valid input format for DateTime. What I mean is that where you are using get_the_date('Ymd', null));
in this statement $listing_date = DateTime::createFromFormat($date_format, get_the_date('Ymd', null));
is not a valid input value.