Advertisement
Guest User

Untitled

a guest
Dec 16th, 2014
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head lang="en">
  4.     <meta charset="UTF-8">
  5.     <title></title>
  6. </head>
  7. <body>
  8. <form method="get">
  9.     <input type="text" name="dateOne"/>
  10.     <input type="text" name="dateTwo"/>
  11.     <input type="submit"/>
  12. </form>
  13.  
  14. <?php
  15. if(isset($_GET['dateOne'], $_GET['dateTwo'])) {
  16.     $startDate = new DateTime($_GET['dateOne']);
  17.     $endDate = new DateTime($_GET['dateTwo']);
  18.     $Thursdays = [];
  19.  
  20.     while ($startDate <= $endDate) {
  21.         $dateString =$startDate->format('d-M-Y');
  22.         $dayOfWeek = date('N', strtotime($dateString));
  23.         if ($dayOfWeek == '4') {
  24.             $Thursdays[] = date_format($startDate, 'd-m-Y');
  25.         }
  26.         $startDate->add(new DateInterval('P1D'));
  27.     }
  28.  
  29.     if (empty($Thursdays)) {
  30.         echo "<h2>No Thursdays</h2>";
  31.     } else {
  32.         echo "<ol>";
  33.         foreach ($Thursdays as $thy) {
  34.             echo "<li>$thy</li>";
  35.         }
  36.         echo "</ol>";
  37.     }
  38. }
  39. ?>
  40.  
  41. </body>
  42. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement