From f6b942f4a72ae04400f499e5e02bb83cfb492af4 Mon Sep 17 00:00:00 2001 From: Lukas Halbritter Date: Sun, 27 Jan 2019 22:40:00 +0100 Subject: [PATCH] Added functions to get first and last day of the year. --- app/Http/helpers.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/Http/helpers.php b/app/Http/helpers.php index c41f710..cc43ca4 100644 --- a/app/Http/helpers.php +++ b/app/Http/helpers.php @@ -106,6 +106,26 @@ function endOfMonth($year, $month, $format='d.m.Y') { ->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. * Returns true, if all fields of $array are null. Returns fals,e otherwise