Create a node With date field By editor, 4 December, 2015 Question How to create and format a date field. It is same as normal node creation but must be in format "Y-m-d" (YYYY-MM-DD) Example: $dateTime = \DateTime::createFromFormat('Y-m-d','2000-01-30'); $newDateString = $dateTime->format('Y-m-d\TH:i:s'); $node = \Drupal\node\Entity\Node::create(array( 'type' => 'article', 'title' => 'The title', 'langcode' => 'en', 'uid' => 1, 'status' => 1, 'body' => array('The body text'), //'field_date' => array("2000-01-30"), 'field_date' => $newDateString, )); $node->save(); Tags Drupal 8 Code Node Add new comment Create a node programmatically in Drupal 8