Added functions to get first and last day of the year.

This commit is contained in:
Lukas Halbritter
2019-01-27 22:40:00 +01:00
parent 05b36d66eb
commit f6b942f4a7
+20
View File
@@ -106,6 +106,26 @@ function endOfMonth($year, $month, $format='d.m.Y') {
->endOfMonth()->format($format); ->endOfMonth()->format($format);
} }
/**
* Return the first day of a given year.
*
* @param string $year
* @return string E. g. 01.01.2018
*/
function firstDayOfYear($year, $format='d.m.Y') {
return Carbon\Carbon::parse('01.01.' . $year)->format($format);
}
/**
* Return the last day of a given year.
*
* @param string $year
* @return string E. g. 31.12.2018
*/
function lastDayOfYear($year, $format='d.m.Y') {
return Carbon\Carbon::parse('31.12.' . $year)->format($format);
}
/** /**
* Check, if all fields of an array are null. * Check, if all fields of an array are null.
* Returns true, if all fields of $array are null. Returns fals,e otherwise * Returns true, if all fields of $array are null. Returns fals,e otherwise