I have a file Commands/DateUpdate.php
protected $signature = 'date:update';
public function handle()
{
$listSchedule = Schedule::where('dateSchedule', '=', strtotime('now'))->get()->toArray();
$dateSchedule = [];
foreach ($listSchedule as $value) {
$dateSchedule[] = $value['dateSchedule'];
}
var_dump($dateSchedule);
// result
// array(3) {
// [0]=>
// string(16) "2023-01-05 09:16"
// [1]=>
// string(16) "2023-01-05 11:45"
// [2]=>
// string(16) "2023-01-05 15:25"
// }
}
In Kernel.php
$schedule->command('date:update');
I want to schedule it according to the time in the $dateSchedule
variable.
Example:
foreach ($dateSchedule as $item) {
->at($item);
};
How can this be done?
2
Answers
You can try by compare current time with dateSchedule
You can use