From 0c09f1b55755d50b03c708fe81c1336fd9d5d39a Mon Sep 17 00:00:00 2001 From: Sander Muller Date: Tue, 2 Dec 2025 14:27:40 +0100 Subject: [PATCH 1/3] add-milliseconds-weeks-and-months-helpers --- src/Illuminate/Support/functions.php | 30 ++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/Illuminate/Support/functions.php b/src/Illuminate/Support/functions.php index 6ae16a07599e..69b37937efee 100644 --- a/src/Illuminate/Support/functions.php +++ b/src/Illuminate/Support/functions.php @@ -66,6 +66,16 @@ function now($tz = null): CarbonInterface } } +if (! function_exists('Illuminate\Support\milliseconds')) { + /** + * Get the current date / time plus the given number of milliseconds. + */ + function milliseconds(int|float $milliseconds): CarbonInterval + { + return CarbonInterval::milliseconds($milliseconds); + } +} + if (! function_exists('Illuminate\Support\seconds')) { /** * Get the current date / time plus the given number of seconds. @@ -106,6 +116,26 @@ function days(int $days): CarbonInterval } } +if (! function_exists('Illuminate\Support\weeks')) { + /** + * Get the current date / time plus the given number of weeks. + */ + function weeks(int $weeks): CarbonInterval + { + return CarbonInterval::weeks($weeks); + } +} + +if (! function_exists('Illuminate\Support\months')) { + /** + * Get the current date / time plus the given number of months. + */ + function months(int $months): CarbonInterval + { + return CarbonInterval::months($months); + } +} + if (! function_exists('Illuminate\Support\years')) { /** * Get the current date / time plus the given number of years. From 86d41bf362c91b28a39b6023fa89c0e69663320b Mon Sep 17 00:00:00 2001 From: Sander Muller Date: Tue, 2 Dec 2025 15:00:17 +0100 Subject: [PATCH 2/3] Update functions.php --- src/Illuminate/Support/functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Support/functions.php b/src/Illuminate/Support/functions.php index 69b37937efee..280cda4c5e6c 100644 --- a/src/Illuminate/Support/functions.php +++ b/src/Illuminate/Support/functions.php @@ -70,7 +70,7 @@ function now($tz = null): CarbonInterface /** * Get the current date / time plus the given number of milliseconds. */ - function milliseconds(int|float $milliseconds): CarbonInterval + function milliseconds(int $milliseconds): CarbonInterval { return CarbonInterval::milliseconds($milliseconds); } From ff62b73545cdf2c61b81958d992e0ca802b5a4d9 Mon Sep 17 00:00:00 2001 From: Sander Muller Date: Tue, 2 Dec 2025 17:07:43 +0100 Subject: [PATCH 3/3] Add microseconds For when a smaller unit than milliseconds is needed, or a decimal value of milliseconds --- src/Illuminate/Support/functions.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Illuminate/Support/functions.php b/src/Illuminate/Support/functions.php index 280cda4c5e6c..0e5e5ff8f80c 100644 --- a/src/Illuminate/Support/functions.php +++ b/src/Illuminate/Support/functions.php @@ -66,6 +66,16 @@ function now($tz = null): CarbonInterface } } +if (! function_exists('Illuminate\Support\microseconds')) { + /** + * Get the current date / time plus the given number of microseconds. + */ + function microseconds(int $microseconds): CarbonInterval + { + return CarbonInterval::microseconds($microseconds); + } +} + if (! function_exists('Illuminate\Support\milliseconds')) { /** * Get the current date / time plus the given number of milliseconds.