Just expanding the answer,
The crontab will work fine, if you are using unix, so we will make that assumption.
First make sure you have PHP built for CLI,
#which php
if it returns then you have it. (Uusally at /usr/local/bin/php)
So to have something run at midnight open this file:
/var/spool/cron/(USER TO RUN AS) or /var/spool/cron/crontabs/(User) depending on the version of Unix you are on.
add this line:
00 00 * /usr/local/bin/php /path/to/your/script 1> /dev/null 2> /dev/null
If you dont have control of cron you could just write something in to one of you main pages that would call it once a night as close to midnight as possible.