How to replace cron with time()

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

I think this will do it:

define('TIME24h', time() - 86400);
$marker_array = file($marker_file);
$marker_array_r = array_reverse($marker_array);
if ($marker_array_r[0] < TIME24h)
$rolltime = $marker_array_r[0] + 86400;
while ($rolltime < TIME24h) //if no visits in last 24hrs
$rolltime = $rolltime + 86400;
$fp = fopen($marker_file,"a");
fwrite($fp, $rolltime);
//code that needs to run once a day goes here

The next visit to the site after a 24-hour interval will trigger the code.
The marker_file will also serve as a log showing each day the scheduled code
was run. Of course this assumes you seed the marker_file with a unix
timestamp of your choice, and that you only need your code to run once each
day, not at a particular time each day.

Site Timeline