I need to pay someone for a live counter that adds one each 1.7 seconds.
It is the real time count of Heart Failures worldwide.
Gary@HealthyHeartTissue.com
Gary
I need to pay someone for a live counter that adds one each 1.7 seconds.
It is the real time count of Heart Failures worldwide.
Gary@HealthyHeartTissue.com
Gary
Here is a simple derivative of the linked thread above.
I want to let you know that this is also a hybrid ( PHP and Javascript). I don't normally use server side time in displaying user time zone related content, but we need a reliable time reference.
our simple function.. save as cases.php
<?php
function get_cases()
{
## define current server time
$time = time();
## define time beginning e.g. january of this year
$beg_time = strtotime('2014-01-01 00:00:00');
## calculate elapsed time since beg_time
$elapsed_time = round($time - $beg_time);
## return everything as array
return array(
'time'=> $time,
'case_today' => round(($time - (strtotime("00:00"))) / 1.7),
'beg_time' => $beg_time,
'elapsed_time' => round($time - $beg_time),
'ytd_cases' => round($elapsed_time / 1.7)
);
}
$res = get_cases();
## test if we can access array output
//echo $res['beg_time'].'<br/>';
//echo $res['time'].'<br/>';
?>
The page that will display your incrementation. Save as counter.php
<?php
require_once('cases.php');
?>
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function getCurrentTime(){
return <?php echo $res['time'];?>;
}
var timeSinceEpoch = getCurrentTime();
//document.write(timeSinceEpoch);
var heartFailure = <?php echo $res['ytd_cases'];?> ; // this is the total cases since beginning
var caseToday = <?php echo $res['case_today'];?>;
function casesAsOfToday(){
caseToday++;
document.getElementById('cases_today').innerHTML = 'Cases today ' + caseToday;
}
function countFailure() {
heartFailure++;
document.getElementById('heart_failure').innerHTML = 'Year to date cases: ' + heartFailure;
}
setInterval('countFailure()', 1700);
setInterval('casesAsOfToday()',1700);
</script>
</head>
<body>
<div id="heart_failure"></div>
<br/>
<div id="cases_today"></div>
</body>
</html>
that's pretty much it. You can style the integer count by adding CSS. So, this
<div id="heart_failure"></div>
can have class attribute
<div id="heart_failure" class="your_class"></div>
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.