You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: helpers.md
+27-2Lines changed: 27 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
-[Available Methods](#available-methods)
5
5
-[Other Utilities](#other-utilities)
6
6
-[Benchmarking](#benchmarking)
7
-
-[Dates](#dates)
7
+
-[Dates and Time](#dates)
8
8
-[Deferred Functions](#deferred-functions)
9
9
-[Lottery](#lottery)
10
10
-[Pipeline](#pipeline)
@@ -3194,7 +3194,7 @@ Sometimes, you may want to benchmark the execution of a callback while still obt
3194
3194
```
3195
3195
3196
3196
<aname="dates"></a>
3197
-
### Dates
3197
+
### Dates and Time
3198
3198
3199
3199
Laravel includes [Carbon](https://carbon.nesbot.com/docs/), a powerful date and time manipulation library. To create a new `Carbon` instance, you may invoke the `now` function. This function is globally available within your Laravel application:
3200
3200
@@ -3210,8 +3210,33 @@ use Illuminate\Support\Carbon;
3210
3210
$now = Carbon::now();
3211
3211
```
3212
3212
3213
+
Laravel also augments `Carbon` instances with `plus` and `minus` methods, allowing easy manipulation of the instance's date and time:
3214
+
3215
+
```php
3216
+
return now()->plus(minutes: 5);
3217
+
return now()->plus(hours: 8);
3218
+
return now()->plus(weeks: 4);
3219
+
3220
+
return now()->minus(minutes: 5);
3221
+
return now()->minus(hours: 8);
3222
+
return now()->minus(weeks: 4);
3223
+
```
3224
+
3213
3225
For a thorough discussion of Carbon and its features, please consult the [official Carbon documentation](https://carbon.nesbot.com/docs/).
3214
3226
3227
+
<aname="interval-functions"></a>
3228
+
#### Interval Functions
3229
+
3230
+
Laravel also offers `seconds`, `minutes`, `hours`, `days`, and `years` functions that return `CarbonInterval` instances, which extend PHP's [DateInterval](https://www.php.net/manual/en/class.dateinterval.php) class. These functions may be used anywhere that Laravel accepts a `DateInterval` instance:
0 commit comments