Hi @madmaxy
You should check for the get_field around everything instead. Since otherwise you attempt to create a datetime etc. with no second parameter so $datum wont be empty.
if( get_field('gultigkeit') ){
$date = DateTime::createFromFormat(‘Ymd’, get_field(‘gultigkeit’));
$datum = $date->format(‘d-m-Y’);
$heute = date(‘d-m-Y’);
}