Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head lang="en">
- <meta charset="UTF-8">
- <title></title>
- </head>
- <body>
- <form method="get">
- <input type="text" name="dateOne"/>
- <input type="text" name="dateTwo"/>
- <input type="submit"/>
- </form>
- <?php
- if(isset($_GET['dateOne'], $_GET['dateTwo'])) {
- $startDate = new DateTime($_GET['dateOne']);
- $endDate = new DateTime($_GET['dateTwo']);
- $Thursdays = [];
- while ($startDate <= $endDate) {
- $dateString =$startDate->format('d-M-Y');
- $dayOfWeek = date('N', strtotime($dateString));
- if ($dayOfWeek == '4') {
- $Thursdays[] = date_format($startDate, 'd-m-Y');
- }
- $startDate->add(new DateInterval('P1D'));
- }
- if (empty($Thursdays)) {
- echo "<h2>No Thursdays</h2>";
- } else {
- echo "<ol>";
- foreach ($Thursdays as $thy) {
- echo "<li>$thy</li>";
- }
- echo "</ol>";
- }
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement