PHP date/time based redirect (embargo)

Sometimes you want to put a (new) site live at a specific time, or redirect users to a different page after a specific date or time (e.g. on an event site, after the event has started).

You can do this using .htaccess files, but a quick and easy way is to create a file, e.g. auto-redirect.php. Then include this file at the top of your existing PHP script, for example your WordPress theme’s functions.php or just in index.php.

Include the script:
include ‘auto-redirect.php’;