数字自动增长

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

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 : 表示每天增长的量。

posted @ 2016-02-16 09:26  卷柏的花期  阅读(316)  评论(0编辑  收藏  举报