数字自动增长

手动指定一个起始值,然后指定开始时间,再指定一个每天增长的量,便可以实现一个按时间自动增长的数字。

1 function randomNumber(s,d,n){
2 
3     var    startDate = new Date(d).getTime(),
4         curDate = new Date().getTime(),
5         ratio = parseFloat(new Number(n/86400).toFixed(4));
6     return parseInt((curDate - startDate)/1000*ratio) + s;
7 
8 }

说明:

  s : 表示起始数量。

  d : 表示起始天数。

  n : 表示每天增长的量。

原文地址:https://www.cnblogs.com/HCJJ/p/5191755.html