Jump to content

[SOLVED] can't get countdown to work


jakebur01

Recommended Posts

I have this script that is supposed to check to see if it is meetingtime if not it is supposed to countdown then start the meeting. $meetingstarttime and $meetingendtime are unix time stamps.

 

<?php

//$meetingstarttime=1218973304; //just a test - delete this line for using database values

$te = date("Y-m-d H:i:s", $meetingstarttime);
$secondsDiff = $meetingstarttime - time();

if ( time() > $meetingendtime) {
echo "Chat closed";
}else
if ( time() <= $meetingstarttime)
{
?>

<div id="content">
        <table class="countTable">
          
           <tr><th colspan="2" id="remain"><?=$te;?></th>
<script type="text/javascript">
v=new Date();
var remain=document.getElementById('remain');
function tremain(){
n=new Date();
s=<?=$secondsDiff;?>-Math.round((n.getTime()-v.getTime())/1000.);
m=0;
h=0;
if(s<0){
remain.innerHTML='Chat Time ';document.location=document.location;
}else{
if(s>59){
m=Math.floor(s/60);
s=s-m*60
}
if(m>59){
h=Math.floor(m/60);
m=m-h*60
} 
if(s<10){
s="0"+s
}
if(m<10){
m="0"+m
}
remain.innerHTML=" "+h+"h "+m+"m "+s+'s';document.title=h+':'+m+':'+s+' .';
window.setTimeout("tremain();",999);
}
}
tremain();
</script>





   </tr>
          
       </table>
    </div>
<?php
}
else
{
$chat->printChat();
}
?>


Link to comment
https://forums.phpfreaks.com/topic/119361-solved-cant-get-countdown-to-work/
Share on other sites


<div id="content">
        <table class="countTable">
          
           <tr><th colspan="2" id="remain"><?=$te;?></th>
<script type="text/javascript">
v=new Date();
var remain=document.getElementById('remain');
function tremain(){
n=new Date();
s=<?=$secondsDiff;?>-Math.round((n.getTime()-v.getTime())/1000.);
m=0;
h=0;
if(s<0){
remain.innerHTML='Chat Time ';document.location=document.location;
}else{
if(s>59){
m=Math.floor(s/60);
s=s-m*60
}
if(m>59){
h=Math.floor(m/60);
m=m-h*60
} 
if(s<10){
s="0"+s
}
if(m<10){
m="0"+m
}
remain.innerHTML=" "+h+"h "+m+"m "+s+'s';document.title=h+':'+m+':'+s+' .';
window.setTimeout("tremain();",999);
}
}
tremain();
</script>





   </tr>
          
       </table>
    </div>




























Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.