Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- date_default_timezone_set('Europe/Sofia');
- $dateOne = DateTime::createFromFormat('d-m-Y', $_GET['dateOne']);
- $dateTwo = DateTime::createFromFormat('d-m-Y', $_GET['dateTwo']);
- $startDate = $dateOne;
- $endDate = $dateTwo;
- if ($dateOne > $dateTwo) {
- $startDate = $dateTwo;
- $endDate = $dateOne;
- }
- $thursdayList = array();
- $date = $startDate;
- while ($date <= $endDate) {
- if ($date->format('l') == 'Thursday') {
- array_push($thursdayList, $date->format('d-m-Y'));
- date_add($date, date_interval_create_from_date_string('6 days'));
- }
- date_add($date, date_interval_create_from_date_string('1 day'));
- }
- if (count($thursdayList) < 1) {
- die('<h2>No Thursdays</h2>');
- }
- echo '<ol>';
- foreach ($thursdayList as $thursday) {
- echo "<li>{$thursday}</li>";
- }
- echo '</ol>';
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement