This is a migrated thread and some comments may be shown as answers.

CountDown Clock

1 Answer 456 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Tina
Top achievements
Rank 2
Tina asked on 24 Apr 2014, 02:16 PM
I need to countdown days, hours, minutes to a future event on a clock type control.  Does anyone have a good example of doing that?

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 25 Apr 2014, 03:14 AM
Hi Tina,

Please have a look into the following sample code snippet to achieve your scenario.

ASPX:
<telerik:RadDateTimePicker ID="raddatetimeFutureDate" runat="server" ClientEvents-OnDateSelected="CountDown">
</telerik:RadDateTimePicker>

JavaScript:
<script type="text/javascript">
    function CountDown(sender,args) {
        var todayDate = new Date(); //current date
        var futureDate = new Date(args.get_newDate());
        futureDate.setHours(10, 25, 10, 10);
        var timeDiff = Math.abs(futureDate.getTime() - todayDate.getTime());
        var CountDays = Math.ceil(timeDiff / (1000 * 3600 * 24));
        var CountHours = Math.abs(todayDate.getHours() - futureDate.getHours());
        var CountMinutes = Math.abs(todayDate.getMinutes() - futureDate.getMinutes());
        alert("Time Remaining is " + CountDays + " days " + CountHours + " hours and  " + CountMinutes + "miutes");
    }      
</script>

Let me know if you have any concern.
Thanks,
Shinu.
Tags
General Discussions
Asked by
Tina
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Share this question
or