AlexKondov

Untitled

Aug 27th, 2014
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.83 KB | None | 0 0
  1.     <?php
  2.         date_default_timezone_set("Europe/Sofia");
  3.  
  4.             $dateOne = strtotime($_GET['dateOne']);
  5.             $dateTwo = strtotime($_GET['dateTwo']);
  6.             $helper;
  7.  
  8.             if ($dateTwo < $dateOne) {
  9.                 $helper = $dateOne;
  10.                 $dateOne = $dateTwo;
  11.                 $dateTwo = $helper;
  12.             }
  13.  
  14.             $totalDays = floor(($dateTwo - $dateOne) / (60 * 60 * 24));
  15.             $current = $dateOne;
  16.             $thursdays = [];
  17.  
  18.            
  19.             for ($i=1; $i <= $totalDays; $i++) {
  20.                 $dayOfWeek = date("N", $current);
  21.  
  22.                 if ($dayOfWeek == 4) {
  23.                     array_push($thursdays, date("d-m-Y", $current));
  24.                 }
  25.                 $current = strtotime("+1 day", $current);
  26.             }
  27.            
  28.             if (count($thursdays) > 0) {
  29.                 echo "<ol>";
  30.                 for ($i=0; $i < count($thursdays); $i++) {
  31.                     echo "<li>$thursdays[$i]</li>";
  32.                 }
  33.                 echo "</ol>";
  34.             }
  35.             else {
  36.                 echo "<h2>No Thursdays</h2>";
  37.             }
  38.     ?>
Advertisement
Add Comment
Please, Sign In to add comment