Skip to content

Commit 7605c76

Browse files
authored
[12.x] Add milliseconds, weeks, and months duration helpers to Illuminate\Support (#57997)
* add-milliseconds-weeks-and-months-helpers * Update functions.php * Add microseconds For when a smaller unit than milliseconds is needed, or a decimal value of milliseconds
1 parent c265a31 commit 7605c76

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/Illuminate/Support/functions.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,26 @@ function now($tz = null): CarbonInterface
6666
}
6767
}
6868

69+
if (! function_exists('Illuminate\Support\microseconds')) {
70+
/**
71+
* Get the current date / time plus the given number of microseconds.
72+
*/
73+
function microseconds(int $microseconds): CarbonInterval
74+
{
75+
return CarbonInterval::microseconds($microseconds);
76+
}
77+
}
78+
79+
if (! function_exists('Illuminate\Support\milliseconds')) {
80+
/**
81+
* Get the current date / time plus the given number of milliseconds.
82+
*/
83+
function milliseconds(int $milliseconds): CarbonInterval
84+
{
85+
return CarbonInterval::milliseconds($milliseconds);
86+
}
87+
}
88+
6989
if (! function_exists('Illuminate\Support\seconds')) {
7090
/**
7191
* Get the current date / time plus the given number of seconds.
@@ -106,6 +126,26 @@ function days(int $days): CarbonInterval
106126
}
107127
}
108128

129+
if (! function_exists('Illuminate\Support\weeks')) {
130+
/**
131+
* Get the current date / time plus the given number of weeks.
132+
*/
133+
function weeks(int $weeks): CarbonInterval
134+
{
135+
return CarbonInterval::weeks($weeks);
136+
}
137+
}
138+
139+
if (! function_exists('Illuminate\Support\months')) {
140+
/**
141+
* Get the current date / time plus the given number of months.
142+
*/
143+
function months(int $months): CarbonInterval
144+
{
145+
return CarbonInterval::months($months);
146+
}
147+
}
148+
109149
if (! function_exists('Illuminate\Support\years')) {
110150
/**
111151
* Get the current date / time plus the given number of years.

0 commit comments

Comments
 (0)