Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Write a PHP script LazySundays.php which prints the dates of all Sundays in the current month.
- <?php
- function getMonthSundays($currentYear, $currentMonth) {
- $sevenDays = new DatePeriod(
- new DateTime("first sunday of $currentYear-$currentMonth"),
- DateInterval::createFromDateString('next sunday'),
- new DateTime("next month $currentYear-$currentMonth-01")
- );
- foreach ($sevenDays as $sunday) {
- echo '<p>' . $sunday->format("jS F, Y") . "</p>\n";
- }
- }
- getMonthSundays(2014, 'August');
- getMonthSundays(2014, '12');
- getMonthSundays(2015, 4);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement