Javascript jquery当前时间戳减去一天(重复30天)
今晚我做这个函数是为了为演示图表页面创建随机数据。我想为过去30天的每一天创建随机数据 我的思考过程是获取当前UTC时间戳,然后为每天的数据减去Javascript jquery当前时间戳减去一天(重复30天),javascript,jquery,Javascript,Jquery,今晚我做这个函数是为了为演示图表页面创建随机数据。我想为过去30天的每一天创建随机数据 我的思考过程是获取当前UTC时间戳,然后为每天的数据减去(count++*3600000)。一切正常,但我的时间戳从未改变,因此每天的数据都是针对当天的。想法 //current timestamp var curr_date = $.now(); //random data generator up to 300 function randomData(label, color) { //cou
(count++*3600000)
。一切正常,但我的时间戳从未改变,因此每天的数据都是针对当天的。想法
//current timestamp
var curr_date = $.now();
//random data generator up to 300
function randomData(label, color) {
//counter
var count = 0;
//rand value
function randValue() {
return Math.floor(Math.random() * 300);
}
series = [
{label: label, color: color,
data: [
[curr_date - (count * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()]
]}
];
return series;
}
我的大脑必须被炒-86400000是js中一天的价值。我的大脑必须被炒-86400000是js中一天的价值。我的大脑必须被炒-86400000是js中一天的价值。我的大脑必须被炒-86400000是js中一天的价值。我已经为此做了一项工作:
我在这里做了一项工作:
我在这里做了一项工作:
我在这里做了一项工作:
//current timestamp
var curr_date = $.now();
//random data generator up to 300
function randomData(label, color) {
//counter
var count = 0;
//rand value
function randValue() {
return Math.floor(Math.random() * 300);
}
//this.test=[count,count++,count++];
this.series = [
{label: label, color: color,
data: [
[curr_date - (count * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()],
[curr_date - (count++ * 3600000), randValue()]
]}
];
}
var randomData=new randomData('label','color');
console.log(randomData.series);