> For the complete documentation index, see [llms.txt](https://venndev.gitbook.io/vapm/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://venndev.gitbook.io/vapm/system/settimeout.md).

# setTimeout()

<pre class="language-php"><code class="lang-php">/**
<strong> * This function is used to run a callback in the event loop with timeout
</strong> */
public static function setTimeout(callable $callback, int $timeout): SampleMacro;
</code></pre>

Similar to JavaScript, simply include a first callback, followed by milliseconds.

The global **`setTimeout()`** method sets a timer which executes a function or specified piece of code once the timer expires.

Example:

```php
System::setTimeout(function() {
    echo "Hello World\n";
}, 5000);
```

Output:

```
Hello World // after 5 seconds.
```

As I said, as well as JavaScript next to setTimeout() there is a method to delete them via clearTimeout().

```php
 /**
  * This function is used to clear the timeout
  */
 public static function clearTimeout(SampleMacro $sampleMacro): void;
```

Example:

```php
$timeout = System::setTimeout(function() {
    echo "Hello World\n";
}, 5000);

System::clearTimeout($timeout);
```

Output:

```
Don't output anything the wallet deleted it.
```
