You are asking about black magic. Are you sure you want to know the answer?
In answer your hypothetical question, "If Google uses PHP for scheduled notifications how do they do it?" the best answer would be cron. It really has nothing to do with PHP, it is a service run by the operating system (at least on *nix-based systems) which wakes up every minute, checks a to-do list, runs things it needs to run, and then goes back to sleep. The "minute" thing is a very important detail: it doesn't run constantly, it doesn't run tasks with a by-the-second precision, only every minute.
Cron can run any executable script, and is designed to run with the permissions of the person who scheduled the cron task, so it can run shell scripts out of your home directory and it can run php scripts if they are correctly configured.
As an alternative to cron, one could also write a new service that continually runs as a daemon, which wakes up every so often to check if notifications need to be sent. You would lose the standardized behavior of cron, but you could do by-the-second scheduling, and anything else your heart desires.
As for knowing when to send notifications, you create a database containing a list of tasks and when they should run, and then find a nicely optimized query to grab the current set and process them. Cron, or your custom service (which you have written in Node.js because all the cool kids are using Node.js), runs this query every minute / every so many seconds. And if you are Google, you then figure out how to scale this out to a thousand machines.