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
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>




























Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.