CountDown Clock

2 posts, 0 answers
  1. Tina
    Tina avatar
    31 posts
    Member since:
    Sep 2007

    Posted 24 Apr 2014 Link to this post

    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?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 24 Apr 2014 in reply to Tina Link to this post

    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.
Back to Top