How do i get grouped random numbers in different time intervals using php
<p>I have failed to find any problem with my code, yet it only outputs numbers from 0 to 20 without following the time restrictions i imposed. Please help me out. Below is the code:</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;?php
    set_time_limit(0);
    class random{
        var $max;
        var $min;
        function irregularnos($min,$max) {
             $num = '';
             $i = 0;
             $this-&gt;min=$min;
             $this-&gt;max=$max;
             while($i &lt; 25)
             {
                 $num .= mt_rand($min,$max);
                 echo $num . "&lt;/br&gt;";
                 $num = '';
                 $i++;
             }
         }
    } 
    $rand1 = new random;
    $rand2 = new random;
    $rand3 = new random; 
    $rand4 = new random;
    date_default_timezone_set('Europe/Berlin');
    $start_time = new DateTime(); //current time 
    while(true){
        if ($start_time-&gt;modify('+1 seconds')&lt;= new DateTime() and  $start_time-&gt;modify('+2      seconds') &gt; new DateTime()) { $rand2-&gt;irregularnos(21,50);}
else  if ($start_time-&gt;modify('+2 seconds') &lt;= new DateTime() and $start_time-   &gt;modify('+3 seconds') &gt; new DateTime()) { $rand3-&gt;irregularnos(51,70);}
else if ($start_time-&gt;modify('+3 seconds') &lt;= new DateTime() and $start_time-&gt;modify('+4 seconds') &gt; new DateTime()) {$rand4-&gt;irregularnos(71,100);}
else if (new DateTime() &lt; $start_time-&gt;modify('+1 seconds')) {$rand1-&gt;irregularnos(0,20);}
else if(new DateTime()&gt; $start_time-&gt;modify('+4 seconds'))  { break;}
    } 
?&gt;
</code></pre>
