I have a External PHP code that is called in Javascript OnLoad. It works, but I would like for it to rerun the php code against a running clock.

Here is how I have it set up. The PHP code is Day/Night code that I setup from existing code. It gives two variables D for Day and N for night. So $output="D" or $output="N" according to sunrise or sunset times.

It is set up in my javascript page as:

//This piece of code is at top of html page
<?php $output = require("DayNight.php"); ?>

// This function is ran OnLoad in the body, it changes the colors of everything on the page with an external JS script.
function PreInitialize() {

$output=new Array(); 
      var $output="<?php echo $output ?>"; 
       _fldregSAV = Color_fldregular;
   if ((typeof $output) != "undefined") {
      if ($output != "A" && $output != "D") {
         $output = "N";
      $output = SetDNmode ($output, 'MASTERDIV1_ashp52');
   else {
      $output = SetDNmode ("N", 'MASTERDIV1_ashp52');
It works fine when you open/start the page or if you refresh the page.

Now what I want to do is have it continually check the computer clock so it will automatically change when the proper time is hit. Right now when the proper time is hit it will only change if you refresh the page.

I am not that familiar with PHP and not sure if there is something I can do in my javascript that will have it run the php code again.

I do have a running clock on my html page and was thinking I could incorporate it into it so that every second it runs the php code to check status and gets the variable "d" or "n" and then runs the function PreInitialize(); to do the change.

Any ideas or help would be appreciated.