如题

解决方案 »

  1.   

        google!有很多!
      

  2.   

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
     Date b= sdf.parse("1987-3-4");
     Date a= new Date();
     long time  = (a.getTime()-b.getTime())/1000/60/60/24;
      

  3.   

    <div id="hxtime" style="padding:5px 0 0 0;width:680px; height:1%; margin:10px auto;border:1px solid blue; "></div>   function ShowTimes(){  
        LeaveTime = AfterTime - new Date();  
        LeaveDays=Math.floor(LeaveTime/(1000*60*60*24));//天  
        LeaveHours=Math.floor(LeaveTime/(1000*60*60)%24);//时  
        LeaveMinutes=Math.floor(LeaveTime/(1000*60)%60);//分  
        LeaveSeconds=Math.floor(LeaveTime/1000%60);//秒   
        var q=1000-new Date().getMilliseconds();  
        if(q<10)
        {  
        q="00"+q;  
        }  
        if(q>=10 && q<100)
        {  
        q="0"+q;  
        }  
        document.getElementById("hxtime").innerHTML="距离下班还有<font color=red>"+LeaveHours+"</font>时<font color=red>"+LeaveMinutes+"</font>分<font color=red>"+LeaveSeconds+"</font>秒<font color=red>"+q+"</font>毫秒";  
    }  
    var AfterTime= new Date();
    AfterTime.setHours(18,0,0,0);  
    setInterval(ShowTimes,100); 
      

  4.   

    <a href="http://www.sina.com" id="a_url"></a>
    <span id="span_timer"></span><script type="text/javascript"> (function() {
        var total = 3; // 倒计时
        var span_timer = document.getElementById("span_timer");
        span_timer.innerHTML = total;
        var timer = setInterval(function() {
            if (total <= 0) {
                location.href = document.getElementById("a_url").href; // 跳转
                clearInterval(timer);
                timer = 0;
            } else span_timer.innerHTML = --total;
        }, 1000);
    })();

        
    </script>csdn的登陆倒计时js