How to retrieve value of start date with format end date?
Try using:

 $datum_deelname = $node-&gt;get('field_optional_enddate')-&gt;end_value;


This will give the optional end date.

If you want to get the normal date as you mentioned you can use as:

 $datum_deelname = $node-&gt;get('field_optional_enddate')-&gt;value;