I'm programmatically creating paragraphs using the following code, but I'm unable to get the date value to store correctly within the date field. It seems to store within the database, yet on the edit page/form for the node, it remains as a blank field.
Any suggestions or insight would be appreciated.
//SET THE DATE
$date = new DrupalDateTime('2017-10-24 13:30:00');
//CREATE THE NEW PARAGRAPH
$paragraph = Paragraph::create([
'type' => 'event_venue',
'field_tickets' => [
["value" => 'Adult Update 1|£30'],
["value" => 'Adult Update 2|£130']
],
'field_date' => array($date->format('Y-m-d H:i:s')),
]);
//SAVE THE PARAGRAPH SO WE CAN ADD THE ENTITY ID TO THE NODE
$paragraph->save();
//LOAD THE NODE
$node = entity_load('node', $nid);
//ADD PARAGRAPH TO THE NODE
$node->field_dates = array(
array(
'target_id' => $venue_information->id(),
'target_revision_id' => $venue_information->getRevisionId(),
)
);
//SAVE THE NODE
$nid = $node->save();