Total members 11889 |It is currently Fri Mar 29, 2024 1:49 pm Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





This is example countdown for time , there is a loop you can remove it to make counter works just one time.
Code:

<html>
<
script language="javascript">
         
    function counter
(){  
        
// End date of counter down. divide by 1000 to get difference in seconds.
        var expireDate = parseInt(Date.parse("Sep 14, 2014")/1000);  
     
        
// Getting the current date.
        var now = new Date();  
        var current 
= parseInt(now.getTime()/1000);  
        var secDifference 
= expireDate - current;  
      
        
//Number of years left to expiration  .
        var yearsDifference = parseInt(secDifference/(60*60*24*365))  
        secDifference 
-= yearsDifference * 60 * 60 * 24 * 365;  
      
        
//Number of days left  to expiration .
        var daysDifference = parseInt(secDifference/(60*60*24));  
        secDifference 
-= daysDifference * 60 * 60 * 24;  
          
        
//Number of hours left  to expiration .
        var hoursDifference = parseInt(secDifference/(60*60));  
        secDifference 
-= hoursDifference * 60 * 60;  
      
        
//Number of minutes left  to expiration .
        var minutesDifference = parseInt(secDifference/(60));  
        secDifference 
-= minutesDifference * 60;  
         
        document
.getElementById("years").innerHTML=yearsDifference; 
        document
.getElementById("days").innerHTML=daysDifference;  
        document
.getElementById("hours").innerHTML=hoursDifference;  
        document
.getElementById("minutes").innerHTML=minutesDifference;  
        document
.getElementById("seconds").innerHTML=secDifference; 
    
}  
</script>
    
<body>  
  <table border="1">  
     <tr>  
      <th>Years</th>  
      <th>  </th>  
      <th>Days</th>  
      <th>  </th>  
      <th>Hours</th>  
      <th>  </th>  
      <th>Minutes</th>  
      <th>  </th>  
      <th>Seconds</th>  
     </tr>  
     <tr>  
      <td align="center"><span id="years"></span></td>  
      <td>:</td>  
      <td align="center"><span id="days"> </span></td>  
      <td>:</td>  
      <td align="center"><span id="hours"> </span></td>  
      <td>:</td>  
      <td align="center"><span id="minutes"> </span></td>  
      <td>:</td>  
      <td align="center"><span id="seconds">  </span></td>  
     </tr>  
    </table>  
    <script language="javascript">
    while(true){
     sleep(100)
    
     counter();
    }
    function sleep(delay)
    {
    var startTime = new Date().getTime();
    setTimeout(counter, 1000) 
    }
    
    </script>
    </body>
</html>




_________________
M. S. Rakha, Ph.D.
Queen's University
Canada


Author:
Mastermind
User avatar Posts: 2715
Have thanks: 74 time
Post new topic Reply to topic  [ 1 post ] 

  Related Posts  to : Time countdown
 redirect after countdown     -  
 What Time Is It?     -  
 run time polymorphism     -  
 explode time     -  
 max execution time     -  
 current system time     -  
 Calculate process time     -  
 How to get system time in java     -  
 login using sessionid or time     -  
 time for which a key was kept pressed by user     -  



Topic Tags

JavaScript Time
cron





Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com