HI, I've got a script which shows elapsed time since a news ticker was last modified by a pseudo-cron job script but I would like the output to update once a second as a real-time clock ...
I've looked at lots of php and java scripts but have been completely unsuccessful in getting the output to refresh every second.
Perhaps one of you experienced coders could help. Here's the code I have at the moment ...
<?php
function calcElapsedTime($time)
{
$diff = time()-$time;
$hrsDiff = floor($diff/60/60);
$diff -= $hrsDiff*60*60;
$minsDiff = floor($diff/60);
$diff -= $minsDiff*60;
$secsDiff = $diff;
// Hours
if ($hrsDiff < 10)
{
echo " 0$hrsDiff :";
}
elseif ($hrsDiff > 9)
{
echo " $hrsDiff :";
}
// Minutes
if ($minsDiff < 10)
{
echo " 0$minsDiff :";
}
elseif ($minsDiff > 9)
{
echo " $minsDiff :";
}
// Seconds
if ($secsDiff < 10)
{
echo " 0$secsDiff";
}
elseif ($secsDiff > 9)
{
echo " $secsDiff";
}
}
calcElapsedTime(filemtime('ticker.htm'));
?>
Any ideas on how to add a "setTimeout()" type of loop to refresh the output once a second would be greatfully recieved ...
Thank you in advance.