entities – how easy it is to get the date when the order is completed?

I need to get the due date (payment) of the last order, but I got some kind of crooked code.

I receive all user orders by request.

      $allOrders = Drupal::entityTypeManager()->getStorage('commerce_order')->loadByProperties(
    ('state' => 'completed',
      'uid' => $uid,

I cannot figure out why the following code is not working


The following code worked for me, I think it is wrong and unnecessary.

      $IndexAr = array_key_last($allOrders);
  $oneIndex = $allOrders($IndexAr);
  $AllValues = $oneIndex->toArray();
  $DataTime = $AllValues("completed")(0)("value");

Here is the data structure:
enter image description here