Skip to content
Snippets Groups Projects

Ptps function 5

Merged Адлан Шамавов requested to merge PTPS_Function_5 into main
Files
2
+ 14
0
@@ -137,5 +137,19 @@ class Functions
* ['name' => 'Посуда','depth' => 1,],]],
* ];
*/
/**
* Функция рассчитывает кол-во дней до нового года
* @param DateTimeImmutable $date дата от которой, необходимо рассчитать кол-во дней
* @return int
* @throws Exception
*/
public function howDaysToNy(DateTimeImmutable $date): int
{
$endYear = date("Y-12-31", date_timestamp_get($date));
$dateInterval = date_diff(new DateTimeImmutable($endYear), $date);
return (int)$dateInterval->format("%a") + 1;
}
}
Loading