Email us at info@henrytech.org to discuss your Drupal Migration today!
Set date values of a node.
use Drupal\node\Entity\Node; $node = Node::load(1); $node->set('field_date', '2025-12-31'); $node->set('field_datetime', '2025-12-31T23:59:59'); $node->set('created', '1760140799'); $node->save();
Create a node and set its fields
use Drupal\node\Entity\Node; $node = Node::create(['type' => 'basic_page']); $node->langcode = "en"; $node->uid = '1'; $node->title = 'A Nice Title'; $node->field_something = $something; $node->set('path', $alias); $node->save();
Comments