How can I programmatically create a node? How can I programmatically create nodes with date and image fields?
I know I can do it in Drupal 7 with the following code.
global $user;
    
$node = new stdClass();
$node-&gt;title = &quot;YOUR TITLE&quot;;
$node-&gt;type = &quot;YOUR_NODE_TYPE&quot;;
node_object_prepare($node);
$node-&gt;language = LANGUAGE_NONE;
$node-&gt;uid = $user-&gt;uid; 
$node-&gt;status = 1; //(1 or 0): published or not
$node-&gt;promote = 0; //(1 or 0): promoted to front page

$existing_filepath = &quot;/home/nzcodarnoc/sites/default/files/imported/picture.jpg&quot;;
$new_filepath = &quot;public://picture.jpg&quot;;
$drupal_file = file_save_data(file_get_contents($existing_filepath), $new_filepath);
$drupal_file-&gt;alt = $node-&gt;title;
$drupal_file-&gt;title = $node-&gt;title;
$node-&gt;field_my_file[$node-&gt;language][0] = get_object_vars($drupal_file);
$node-&gt;birth_date[LANGUAGE_NONE][0]['value'] = time();  
$node = node_submit($node);
node_save($node);

What is the equivalent code for Drupal 8?
The following code will help you to save an image in a new node.
use \Drupal\node\Entity\Node;
use \Drupal\file\Entity\File;
 
// Create file object from remote URL.
$data = file_get_contents('https://www.drupal.org/files/druplicon.small_.png');
$file = file_save_data($data, 'public://druplicon.png', FILE_EXISTS_REPLACE);
 
// Create node object with attached file.
$node = Node::create([
  'type'        =&gt; 'article',
  'title'       =&gt; 'Druplicon test',
  'field_image' =&gt; [
    'target_id' =&gt; $file-&gt;id(),
    'alt' =&gt; 'Hello world',
    'title' =&gt; 'Goodbye world'
  ],
]);
$node-&gt;save();