开发者

jquery countdown plugin problem

开发者 https://www.devze.com 2023-02-09 14:58 出处:网络
I want to show jquery countdown timer, but want to show only minutes and seconds. it is fine i , can achieve by

I want to show jquery countdown timer, but want to show only minutes and seconds. it is fine i , can achieve by

$('#defaultCountdown').countdown({ until: dt, format: 'YOWDHMS', significant: 2 });

but it by default taking computer date time. I have picked the date and time from my databas开发者_StackOverflowe. and want to set to "dt" here. but it is not setting the date as i am using this code:

 $(function() {
            var totalTime = document.getElementById("testTime").value;
 var dt = new Date();
            dt.setDate(totalTime);
             $('#defaultCountdown').countdown({ until: dt, format: 'YOWDHMS', significant: 2 });


        });

this is my script. what should be the problem? I think setDate is for only date . where as i have value in "totalTime" ="5/12/2010 00:05:25 Pm" how to set full date to Date injavascript


"SELECT TIME_TO_SEC( TIMEDIFF(yourtable_field, NOW( ) ) ) AS clock FROM table "

change your timestamb in to seconds by above query. store this this time in some HTML element for

example : add some hidden text field with id clock and value= echo $clock --in php

then it's simple

<script type="text/javascript">

var clocktime =$('#clock').val();

$('#countbox').countdown({

layout:'{mnn} : {snn}',
    timeSeparator: ':', 

until: +clocktime
});
</script>


I got the way. It was too easy but i spent lot of time.I used this script:

        $(function() {
            var totalTime = document.getElementById("testTime").value; //get minutes value from code behind in hidden filed or use some other way to get value.

            var min = totalTime; 
            var sec = 00;
            $('#defaultCountdown').countdown({ until: '+' + min + 'm +' + sec + 's', format: 'YOWDHMS', significant: 2 });
 });

It is perfectly showing me minute-seconds countdown timer.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号