Here's the function. $filewritten is the name of a file that the WinBatch script creates, containing the date and time it last executed successfully. $program is the name of the WinBatch script to be executed. $time2pass is the amount of time to delay before running the WinBatch script again.
function time2update($filewritten, $program, $time2pass){
$Diff = 0;
$program = "WinBatchScripts/".$program;
// if it has been Diff minutes since the cleaned file was updated, it's time to update it again
$Diff = intval((time() - filemtime("$filewritten"))/60); //(divide by number sec/min) number of minutes since file updated without errors;
if (!file_exists($filewritten)){echo "\n\r $filewritten does not exist.\n\r";}
else {echo "\n\r It has been $Diff minutes since $filewritten was updated.\n\r";}
if ($Diff > $time2pass OR !file_exists($filewritten))
{
echo "\n\r Time to update $program!\n\r";
system('\php5\php.exe ' . $program);
}
else {echo "\n\r Only $Diff minutes have passed. The file does not need to be updated yet. \n\r";};
}