Question about time function in php?

  • Thread starter Thread starter Blackcompe
  • Start date Start date
How can I add a function that is executed at a certain time? Let's say I want to call function(), but have it called on a certain date. How would I do this?
 
Save this as timep.php, it is better that you put this timep.php on an iframe within your webpage so that it will run independently since it is reloading every few seconds

<html>
<head>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
redirTime = "2000";
redirURL = "timep.php";
function redirTimer() { self.setTimeout("self.location.href = redirURL;",redirTime); }
// End -->
//window.onload="redirTimer";
</script>
<head>
<body onLoad="redirTimer()">
<?php

$datev="01/01/2009 10:25:22"; //desired date /time
$datep=date('Y-m-d H:i:s'); // current time

if($datev <= $datep) {

echo "call your function name here";

}
?>
 
Back
Top