Loading index.php +7 −0 Original line number Diff line number Diff line Loading @@ -94,5 +94,12 @@ print $e->getMessage(); } ?> <h1>Function 7</h1> <?php print "<h2>Разница дней: </h2>"; print $func->diffDays(new DateTimeImmutable(), new DateTimeImmutable("2025-01-01")); ?> </body> </html> No newline at end of file src/Functions.php +12 −0 Original line number Diff line number Diff line Loading @@ -169,5 +169,17 @@ class Functions yield new DateTimeImmutable($day->format("Y-m-d")); } } /** * Вернет кол-во дней между датами * @param DateTimeImmutable $dateStart дата начала * @param DateTimeImmutable $dateEnd дата окончания * @return int */ public function diffDays(DateTimeImmutable $dateStart, DateTimeImmutable $dateEnd): int { $dateInterval = date_diff($dateStart, $dateEnd); return (int)$dateInterval->format("%a") ; } } Loading
index.php +7 −0 Original line number Diff line number Diff line Loading @@ -94,5 +94,12 @@ print $e->getMessage(); } ?> <h1>Function 7</h1> <?php print "<h2>Разница дней: </h2>"; print $func->diffDays(new DateTimeImmutable(), new DateTimeImmutable("2025-01-01")); ?> </body> </html> No newline at end of file
src/Functions.php +12 −0 Original line number Diff line number Diff line Loading @@ -169,5 +169,17 @@ class Functions yield new DateTimeImmutable($day->format("Y-m-d")); } } /** * Вернет кол-во дней между датами * @param DateTimeImmutable $dateStart дата начала * @param DateTimeImmutable $dateEnd дата окончания * @return int */ public function diffDays(DateTimeImmutable $dateStart, DateTimeImmutable $dateEnd): int { $dateInterval = date_diff($dateStart, $dateEnd); return (int)$dateInterval->format("%a") ; } }