Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript jquery当前时间戳减去一天(重复30天)_Javascript_Jquery - Fatal编程技术网

Javascript jquery当前时间戳减去一天(重复30天)

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

今晚我做这个函数是为了为演示图表页面创建随机数据。我想为过去30天的每一天创建随机数据

我的思考过程是获取当前UTC时间戳,然后为每天的数据减去
(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);