So I am calculating an equation so that I can echo out a statistic. This statistic will be bounced back to HTML via ajax and written out to the user. a setInterval will make sure that it gets updated real time. It is very similar to this http://www.usagain.com/ on the left hand side. The problem is I want to start this incrementation at a certain number.
I’m basing it off of the $_SERVER[REQUEST_TIME] so that it always increments and only ever gets reset once it reaches its max. The problem is I need to define a starting number. Here is the equation that user Uboonto came up with:
value = ( timestamp % ((max_limit - min_limit) / 1.5 ) ) * 1.5 + min_limit
This will increment ever second by 1.5 – the problem is that this equation starts randomly between $min and $max instead at a starting number I define. Does anybody know how to modify this equation so I can have a starting number that I can define?
I tried:
value = ( (timestamp + modifier) % ((max_limit - min_limit) / 1.5 ) ) * 1.5 + min_limit
and
value = ( (timestamp - modifier) % ((max_limit - min_limit) / 1.5 ) ) * 1.5 + min_limit
but no luck. I’m open to suggestions.
One approach would be to just calculate the difference between some arbitrary point in time and a known value at that time and multiply by the number of increments per second: