测试彩票,生成一天的序列号,按照当前时间获取当前期号

 public function insert_num()
    {
        $start = date("Y-m-d") . ' 05:00';//凌晨五点开始
        $re = Db::name('open')->find();
        $now = (int)date("Ymd");//当天的日期
        $res = (int)substr($re['number'],0,8);//查询数据库的日期
        if ($now == $res){
            $this->error('数据已经存在请勿重复生成');
        }
        $data = array();
        for ($i = 1; $i <= 264; $i++) {
            $data[$i]['number'] = date("Ymd") . sprintf("%02d", $i);
            $data[$i]['type'] = 1;
//            $data[$i]['time'] = time() + 300000 * $i;
            $data[$i]['time'] = date("Y-m-d H:i",strtotime($start)+300*$i);
            $data[$i]['data'] = rand(0, 9) . ',' . rand(0, 9) . ',' . rand(0, 9) . ',' . rand(0, 9) . ',' . rand(0, 9);
        }
//        dump($data);
        $re = Db::name('open')->insertAll($data);
        if ($re) {
            $this->success('数据生成成功');
        } else {
            $this->error('数据生成失败');
        }
    }

输出源
    public function test(){
        $time = date("Y-m-d H:i:s");
        $all = Db::name('open')->where('time','>', $time)->find();
        return json_encode($all,true);

    }

猜你喜欢

转载自blog.csdn.net/qq_42841183/article/details/84612233
今日推荐