entities – "EntityMetadataWrapperException: Invalid data value given. Make sure it matches the data type and format required for the date field"


I am working on creating an event calendar and therefore I created a custom module to save events in custom content type. I installed the Entity and Date modules, and created a date field (partner_event_date) that accepts values ​​from and to date.

In my custom module, I am using the following code.

$wrapper->field_partner_event_date->set(array(
  'value' => date('Y-m-d H:i:s',$dateFrom),
  'value2' => date('Y-m-d H:i:s', $dateTo),
));

The following output is displayed at the top of the screen.

array(
  'value' => '2022-02-05 00:00:00',
  'value2' => '2024-07-03 00:00:00',
)

The error I get is the following.

EntityMetadataWrapperException: Invalid data value given. Make sure it matches the required data type and format. Value in node () -> field_partner_event_date :. in EntityMetadataWrapper-> set () (line 122 of /sites/all/modules/entity/includes/entity.wrapper.inc).

I installed my module in a new Drupal installation. It works fine, while on the client site (which is already built), when I installed and configured it, I see that error message. Can anyone help with this?