0

I am using this javascript countdown clock: https://github.com/nikhiln/Circular-Countdown

I have got it working fine but now I am trying to pass in variables into its setup to allow me to control it via buttons.

It is setup via

$(".divName").ccountdown(2016,11,24, '10:40');

So Instead of that date I want to pass in variables, for example.

            var date = new Date();
            var EndTime = new Date(date);
            EndTime.setMinutes(date.getMinutes() + 50);
            var years = EndTime.getFullYear();
            var months = EndTime.getMonth();
            months = months + 1;
            var days = EndTime.getUTCDate();
            var hours = EndTime.getHours();
            var minutes = ('0'+EndTime.getMinutes()).slice(-2);
            var timeString = " '" + hours + ":" + minutes +"'";
            $(".heatingTimer").ccountdown(years,months,days,timeString);

However this approach doesn't work. I am not sure how to pass in the variables in the format that is expeceted.

1 Answer 1

2

Your code is fine, you only have a typo in your code (or an error), you should pass the time as a string and you are adding extra single quotes, remove the quotes and it should work as expected:

var timeString = hours + ":" + minutes;
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks, for some reason I thought it had to be passed in as '10:42' but it works without the single quotes just fine. Cheers
That happens, please close this question marking the answer
@user3473406 Single quotes are the syntax for typing literal strings, they're not actually part of the string data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.