Newer
Older
/**
* Вернет все пятницы 13 в году
* @param int $yaer год, в котором необходимо произвести расчет
* @return DateTimeImmutable[]
function countFriday13(int $year): iterable {
$stardDate = new DateTime("{$year}-01-01 Friday");
$year += 1;
$endDate = new DateTime("{$year}-01-01");
$interval = new DateInterval('P7D');
foreach(new DatePeriod($stardDate, $interval, $endDate) as $day) {
yield new DateTimeImmutable($day->format("Y-m-d"));
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<?php
foreach(countFriday13(2024) as $date) {
print($date->format("Y-m-d l") . "\n");
}