Drupal 8+ delete node using some criteria programmatically
Here are the two methods to delete the nodes in Drupal 8 programmatically.
1) Using NID
use Drupal\node\Entity\Node;
$nid = 123;
$node = Node::load($nid);
// or
$node = \Drupal::entityTypeManager()->getStorage('node')->load($nid);
// Check if node exists with the given nid.
if ($node) {
$node->delete();
}
2) Using some criteria (for example, older than 90 days)