How in php to defer the function execution time?

Write the bot in php for VK. The task is this: the bot write "Hello" he says "Bye", but only after 2 hours.

That's part of the code that is responsible for sending the response message if writing to him, "hi."

case strstr($message,'Hello') :

 $request_params = array( 
 'message' => "Until", 
 'user_id' => $user_id, 
 'access_token' => $token, 
 'v' => '5.0' 
 ); 
 $get_params = http_build_query($request_params);

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, 'https://api.vk.com/method/messages.send'); 
curl_setopt($ch, CURLOPT_POST, true); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $get_params);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);curl_close($ch); break;


If you leave everything like that, then fine – the bot works instantly respond and life is good.
How to get him to do it in an hour/two after receiving the message?

Sleep(10) – working. (but I understand that this function anywhere in the script causes it to freeze for 10 seconds)
And if you bet more, the requests begin to pour in several times, the bot can begin to send messages 3-4 times.

In what direction is there to think?
June 14th 19 at 18:52
3 answers
June 14th 19 at 18:54
Think in the direction of CRON
Yeah, update: answers are store in the database in field of type datetime (or some other type of date) keep adding the script which will run the crown to make a selection from the database by this field. To nebylo replays - highlight the record in the database in a separate field. - terrell_Satterfield commented on June 14th 19 at 18:57
June 14th 19 at 18:56
Cron or server queues + worker.
June 14th 19 at 18:58
Database + CRON

Find more questions by tags BotsPHPVKontakte