解决方案 »

  1.   


    <script type="text/javascript">
           function fresh() {
                var d = "2014-05-25";
                var endtime = new Date(d);
                var nowtime = new Date();
                var leftsecond = parseInt((endtime.getTime() - nowtime.getTime()) / 1000);
                d = parseInt(leftsecond / 3600 / 24);
                h = parseInt((leftsecond / 3600) % 24);
                m = parseInt((leftsecond / 60) % 60);
                s = parseInt(leftsecond % 60);
                var td = d * 24 + h;
                $("#emH").html(td);
                $("#emM").html(m);
                $("#emS").html(s);
                if (leftsecond <= 0) {
                        $("#emH").html("00");
                        $("#emM").html("00");
                        $("#emS").html("00");
                    clearInterval(sh);
                }
            }
            fresh();
            var sh;
            sh = setInterval(fresh, 1000);  
        </script><div class="hd">
             <div class="floatleft clock">
                       <em id="emH"></em> <strong>:</strong><em id="emM"></em><strong>:</strong><em id="emS"></em>
             </div>
     </div>
      

  2.   

    我要多个限时的,不过我已经找到你啦,还是要感谢你!
        <script type="text/javascript">
            $(document).ready(function () {
                givetime();
            })
            var endtimes = new Array();//结束时间
            var nowtimes;
            function givetime() {
                endtimes[0] = document.getElementById("times0").attributes["data"].nodeValue;
                endtimes[1] = document.getElementById("times1").attributes["data"].nodeValue;
                endtimes[2] = document.getElementById("times2").attributes["data"].nodeValue;
                endtimes[3] = document.getElementById("times3").attributes["data"].nodeValue;
                var myDate = new Date();
                var month = myDate.getMonth() + 1;
                nowtimes = new Date(month + "/" + myDate.getDate() + "/" + myDate.getFullYear() + " " + myDate.getHours() + ":" + myDate.getMinutes() + ":" + myDate.getSeconds());//当前服务器时间
                window.setTimeout("DownCount()", 1000)
            }
            function DownCount() {
                nowtimes = Number(nowtimes) + 1000;
                for (var i = 0; i <= 3; i++) {
                    var theDay = new Date(endtimes[i]);
                    theDay = theDay++;
                    if (theDay <= nowtimes) {
                        document.getElementById("times" + i).innerHTML = "限购时间:抢购已结束";
                    }
                    else {
                        timechange(theDay, i);                }
                }
                window.setTimeout("DownCount()", 1000)
            }
            function timechange(theDay, i) {
                var theDays = new Date(theDay);
                var seconds = (theDays - nowtimes) / 1000;
                var minutes = Math.floor(seconds / 60);
                var hours = Math.floor(minutes / 60);
                var days = Math.floor(hours / 24);
                var CDay = days;
                var CHour = hours % 24;
                var CMinute = minutes % 60;
                var CSecond = seconds % 60;
                var CHour = CHour + CDay * 24;
                if (CMinute < 10) {
                    CMinute = "0" + CMinute;
                }
                if (CHour < 10) {
                    CHour = "0" + CHour;
                }
                if (CSecond < 10) {
                    CSecond = "0" + CSecond;
                }
                document.getElementById("times" + i).innerHTML = "限购时间:" + CHour + "小时" + CMinute + "分钟" + CSecond + "秒";
            }
        </script>for (int k = 0; k < kcount; k++)
    {
    sbnew.Append("<p><div class = \"daojishi\" style=\"float:left;\"><div id = \"times" + k + "\" data= \"" + ("04/30/2014,23:30:00") + "\" style=\"float:left;\"></div></div><br></p>");
    }
    我这样做的