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

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

相关文章:

  • 2021-07-25
  • 2021-08-18
  • 2022-12-23
  • 2022-12-23
  • 2021-11-17
  • 2021-11-02
  • 2021-07-07
  • 2021-06-01
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-17
相关资源
相似解决方案