The Laravel team released version 12.40.0 this week with new time helper functions, the ability to schedule tasks to run on specific days, pausing and resuming queues, and more.
Time Helpers
Taylor Otwell added time helper functions to the Illuminate\Support namespace and new methods on the support Carbon class:
use Illuminate\Support\Carbon;
// Plus and minus methods support years, months, weeks,
// days, hours, minutes, seconds, microseconds.
Carbon::now()->plus(years: 1, days: 5);
Carbon::now()->minus(weeks: 4);The support namespace has the following helpers, which return a CarbonInterval instance:
use function Illuminate\Support\{seconds, minutes, hours, days, years};
seconds(5);
minutes(5);
hours(1);
days(30);
years(1);
/*
Carbon\CarbonInterval {#1277
interval: + 1y,
}
*/Here are a few examples of how you might use the support Carbon methods and helper functions:
use function Illuminate\Support\minutes;
Cache::put('name', 'Taylor', minutes(5));
Invitation::create([
'expires_at' => now()->plus(weeks: 1),
]);Schedule Tasks on Specific Days
Yousef Kadah contributed a daysOfMonth() method to run tasks on multiple, specific days of the month:
// Variadic syntax
$schedule->command('generate-reports')
->daysOfMonth(1, 10, 20);
// Array syntax
$schedule->command('generate-reports')
->daysOfMonth([1, 10, 20]);Encoding Validation Rule
Jamie York contributed an encoding validation rule that checks the contents of a file and ensures it matches a specific encoding:
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\Rules\File;
Validator::validate($input, [
'attachment' => [
'required',
File::types(['csv'])->encoding('utf-8'),
],
]);Pause/Resume a Queue
Yousef Kadah contributed the ability to pause and resume queues using a command. The queue argument is the connection and queue name. For example, the following is the database connection and default is the queue name:
php artisan queue:pause database:default
php artisan queue:continue database:defaultSee the documentation for details on pausing and resuming queue workers.









