I had a situation recently where I needed to delete both a Drupal user account and a CiviCRM contact at the same time. This was to rid SPAM from the system that was made years ago before there was a CAPTCHA in place.
In Drupal 7 we had the LoginToboggan module, but this is not available for Drupal 8. I needed to replace the "Delete unvalidated users after" x days feature from LoginToboggan so I wrote some quick code that I want to add it in here.
In a module we can create a function that will delete our unvalidated [sic] users after a set number of days.
First, I need to define a timestamp for today (right now).