Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- date_default_timezone_set("Europe/Sofia");
- $dateOne = strtotime($_GET['dateOne']);
- $dateTwo = strtotime($_GET['dateTwo']);
- $helper;
- if ($dateTwo < $dateOne) {
- $helper = $dateOne;
- $dateOne = $dateTwo;
- $dateTwo = $helper;
- }
- $totalDays = floor(($dateTwo - $dateOne) / (60 * 60 * 24));
- $current = $dateOne;
- $thursdays = [];
- for ($i=1; $i <= $totalDays; $i++) {
- $dayOfWeek = date("N", $current);
- if ($dayOfWeek == 4) {
- array_push($thursdays, date("d-m-Y", $current));
- }
- $current = strtotime("+1 day", $current);
- }
- if (count($thursdays) > 0) {
- echo "<ol>";
- for ($i=0; $i < count($thursdays); $i++) {
- echo "<li>$thursdays[$i]</li>";
- }
- echo "</ol>";
- }
- else {
- echo "<h2>No Thursdays</h2>";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment