addDays(21); $data = ['date' => $trialExpires->toDateString(), 'tip' => ' ']; // $result = Db::table("demo")->where("id",1)->find(); // dump($result); Db::table('time_log')->insert($data); return Result::show(200, 'ok', ['time' => $trialExpires]); } /** * 每天访问一次的任务 */ public function scheduled_tasks($name = 'ThinkPHP6') { $db_time = Db::table('time_log')->where('id', Db::table('time_log')->max('id'))->first(); //dump($db_time); $time = $db_time['date']; // 获取当前时间 $current = Carbon::now(); for ($i = 0; $i < 8; $i++) { $current->subDay($i); if (strcmp($current->toDateString(), $time) == 0) { echo "to do "; //$this->updated(""); $i == 7 ? $this->updated("") : ''; return Result::show(200, 'ok', ['time' => $current->toDateString(), 'time2' => $time]); } } } public function send_msg($title, $body) { } }