Search code examples
phpdatehour

php script working every friday


I have this script that is working every day between 2 hours. Now, I have 2 questions: 1) how do I make it work only every friday, not all days? 2) how do I use minutes to m code? $hour:$min > 8:15 is not working

<?php
$hour = date('G'); 
if ($hour >= 8 && $hour <= 10) { 
  include('facut_mine2.php');

 } 
?>

Thanks!


Solution

  • use date('w') to get weekday

    <?php
    $start = strtotime('8:15');
    $end = strtotime('9:45');
    
    if(date('w') == 5){ // day 5 = Friday
        $timenow = date('U'); 
        if ($timenow >= $start && $timenow <= $end) { 
          include('facut_mine2.php');
        } 
    }
    ?>