Advertisement
Venciity

Meeting Dates 90/100 Time limit

Aug 27th, 2014
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.70 KB | None | 0 0
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>Meeting Dates</title>
  6.     <style>
  7.         body {
  8.             font-family: tahoma;
  9.         }
  10.     </style>
  11. </head>
  12. <body>
  13.     <form action="" method="get">
  14.         <input type="text" name="dateOne" value="31-12-2014"/>
  15.         <input type="text" name="dateTwo" value="01-01-2014"/>
  16.         <input type="submit" value="Submit"/>
  17.     </form>
  18.     <?php
  19.         if (isset($_GET['dateOne']) && isset($_GET['dateTwo'])) {
  20.             date_default_timezone_set('Europe/Sofia');
  21.             $firstDate = strtotime($_GET['dateOne']);
  22.             $secondDate = strtotime($_GET['dateTwo']);
  23.             if ($firstDate > $secondDate) {
  24.                 $firstDate = $firstDate + $secondDate;
  25.                 $secondDate = $firstDate - $secondDate;
  26.                 $firstDate = $firstDate - $secondDate;
  27.             }
  28.             $thursDays = [];
  29.             $AllDays = floor(($secondDate - $firstDate)/(60*60*24)) + 1;
  30.  
  31.             $currentDate = $firstDate;
  32.  
  33.             for ($i = 0; $i < $AllDays; $i++) {
  34.                 $dayOfWeek = date('N', $currentDate);
  35.                 if ($dayOfWeek == 4) {
  36.                     array_push($thursDays , date("d-m-Y", $currentDate));
  37.                 }
  38.                 $currentDate = strtotime('+1 day', $currentDate);
  39.             }
  40.  
  41.             if (count($thursDays) > 0) {
  42.                 echo '<ol>';
  43.                 foreach ($thursDays as $thursDay) {
  44.                     echo '<li>' . $thursDay . '</li>';
  45.                 }
  46.                 echo '</ol>';
  47.             }
  48.             else {
  49.                 echo '<h2>No Thursdays</h2>';
  50.             }
  51.         }
  52.     ?>
  53. </body>
  54. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement