Counter with automatic increment each day

731 Views Asked by At

Hi I want a counter which increments each day by 3 or a number between 1-3.

I got the base code

<script type="text/javascript"><!--
jQuery(function($) {
    $('.timer').countTo({
        from: 0,
        to: 2487,
        speed: 3500,
        refreshInterval: 50,
        onComplete: function(value) {
            console.debug(this);
        }
    });
});

//-->

How do I implement a dynamnic increase every day?

1

There are 1 best solutions below

2
On

One option:

place a start day in your code, like 2015-06-20. Get the difference from that day and now (2015-06-23 - 2015-06-20 = 3). You can just multiply the difference with 3.

Another one

If you want to increment between 1-3 randomly and you want the increment to be saved, you need either an algorithm to calculate the factor based on a date (then you have to know the start date), or save the increment each day to database, so you can fetch it an sum it up.